Click to See Complete Forum and Search --> : How to setup cronjob
atortega
10-26-2004, 10:13 PM
Hi!
I had a php code that will send an email notice on 24 hours before my clients reservation date which is stored in mysql database.
The problem is that the code only works if I manually run the module everyday.
How can I set it up as a cronjob to run everyday?
Thanks.
atortega
ray326
10-27-2004, 01:44 PM
man cron
man crontab
atortega
10-28-2004, 03:27 AM
Thanks.
I had included the following line on my crontab file to run every 1:00 in the morning.:
0 1 * * * lynx -dump http://dumingag.net/automate.php > /dev/null
Is the entry on the file is correct? If not, what is theproper syntax.
atortega
ray326
10-28-2004, 02:11 PM
I'm no BOFH but that looks ok to me.
atortega
11-22-2004, 10:58 PM
All the while, I thought that the line below works but in reality it did not work.
0 1 * * * lynx -dump http://dumingag.net/automate.php > /dev/null
During my testing, I tried to run this line below directly to the shell prompt and it works.
lynx -dump "http://dumingag.thefreebizhost.com"
When I created a crontab file like this:
0 1 * * * lynx -dump "http://dumingag.thefreebizhost.com"
0 1 * * * echo "Sample Text to Display every 1 am."
The first line did not work but the second line works. So I presumed that the cron activates the job but the problem is why the first job did not work?
Is there anything I had to set before I could use the lynx command to run as a cronjob?
Please help.
ray326
11-23-2004, 12:29 AM
These are just wild guesses so salt to taste. I really have no idea.
Maybe the shell that cron runs can't find lynx. Is it in the same dir as echo?
Maybe lynx needs some environment setting that isn't there running under cron.
Maybe lynx doesn't like the user "running" cron. Some programs either require root or will not allow root to run them.
Are there no log messages associated with the failures?
atortega
11-23-2004, 12:58 AM
There are no log messages associated to the failure. Tha's why I did not notice it at first.
Lynx is a global command. You can run it in any directory.
Stephen Philbin
11-23-2004, 03:45 AM
I shalln't bother you with annoying questions, but any links to some good reading on this you can offer?
atortega
11-23-2004, 04:51 AM
Below are some useful links that I have read.
===================
www.uwsg.indiana.edu/usail/automation/cron.html (http://www.uwsg.indiana.edu/usail/automation/cron.html)
http://www.freebsd.org/cgi/man.cgi?query=cron&sektion=8
kb.indiana.edu/data/afiz.html (http://kb.indiana.edu/data/afiz.html)
======================
NogDog
11-23-2004, 09:57 AM
cron normally runs from the Bourne shell (sh), whereas most *nix users run CSH or sometimes KSH by default. So, to get the correct search path and other environment variables, you may need to launch your cron job from your default shell:
0 1 * * * csh -c "lynx -dump http://dumingag.net/automate.php > /dev/null"
Stephen Philbin
11-23-2004, 06:36 PM
Is bash (bourne again shell) ok? That's my default shell on SuSE. Any differences I should watch out for that ya know of? Or should I be fine?
ray326
11-23-2004, 08:27 PM
Bash is almost universally the shell Linux systems so that's what you'd expect to be the default for cron there. In fact I bet 'sh' is linked to 'bash'.
atortega
11-24-2004, 12:45 AM
I tried the code which NogDog reccommends but still it didn't run.
Is this a problem with lynx being run as a cron job?
atortega
11-24-2004, 02:23 AM
Finally I got it run!!!
Thanks to all the guys who responded to my query.
Here's my final setting of my crontab file:
0 1 * * * /usr/local/bin/lynx -dump http://storycorps.securesites.net/DEVELOPMENT/secureStoryBooth/admin/automate.php > /dev/null
It is my obervation that whenever we used lynx in the crontab, we should include its full path otherwise it will not worked.
Once again, thanks to all of you.
ray326
11-24-2004, 10:38 PM
The usr bin directories aren't in root's path because they contain questionable code so that may be an indication there of why it wasn't working.