Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm having problems with cron on mandrake 10.0 official.
I'm just trying to run a simple script (called "test-script"):
#!/bin/sh
echo "this is a test" > /var/www/test.txt
here is what my crontab looks like:
08 10 * * * root /root/test-script
which should cause "test-script" to run as root at 10:08 (right?)
at 10:09 this is what the end of /var/log/cron/info looks like:
Nov 28 10:08:00 justice CROND[1419]: (root) CMD (root /root/test-script)
Nov 28 10:08:00 justice CROND[1418]: (root) MAIL (mailed 41 bytes of output but got status 0xffffffff )
so it looks like the script got executed.
but /var/www/test.txt does not exist.
can anyone tell me what i'm doing wrong?
thanks in advance,
dbc
ps: the script runs just fine from the command line:
[root@justice root]# ls -l /root/test-script
-rwxr-xr-x 1 root root 53 Nov 28 10:05 /root/test-script*
[root@justice root]# ls -l /var/www/test.txt
ls: /var/www/test.txt: No such file or directory
[root@justice root]# . test-script
[root@justice root]# more /var/www/test.txt
this is a test
[root@justice root]#
you can see that "test-script" is executable, and that it creates the file when run. but it doesn't look like cron is actually running the script, and i can't find any useful information in the error log (unless maybe i'm looking in the wrong place!)
"the script runs just fine from the command line:"
"so it looks like the script got executed.
but /var/www/test.txt does not exist."
The PATH that cron runs with is pretty skimpy. So cron starts the /root/test-script script and /root/test-script probably fails on "bash command not found" which message is not displayed on the screen. Try setting your PATH in /root/test-script so that the cron demon can find bash and other common commands:
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
echo "this is a test" > /var/www/test.txt
To me it looks like it's trying to start a program called root with your script as parameter. Try to remove the sixth parameter and see what happens. Is there any message in root's mail ? Just type 'mail' as root, don't know what the status code means, though.
Originally posted by LasseW To me it looks like it's trying to start a program called root with your script as parameter. Try to remove the sixth parameter and see what happens. Is there any message in root's mail ? Just type 'mail' as root, don't know what the status code means, though.
From doing a little Googgle searching, I'm willing to bet the status code meant the message couldn't be delivered and delivery would be tried again in the future. I'm wondering if your sendmail is set up and usable? I don't see that you mentioned if you normally use it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.