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 have a backup script that I run on a few machines, but I'm having a problem with one of them. The script is sitting under /etc/cron.daily, but it isn't run when cron.daily is run. When it is run, it should put the date in a log file, but it doesn't, although it did several weeks ago. I've run cron directly, so I know it's not a problem with cron. I can run the script directly.
cron has a different PATH than running from the command line. It is a common problem for a script to work from the command line and not work in cron. You can fix this problem by using the complete path for every command in your script.
Another solution is to set the PATH in the cron script to be exactly the same as the PATH used at the command line.
You should do as Jailbait suggests. One difference could be that on that computer, one of the commands is aliased and that is causing a problem. It is standard practice to always include full pathnames in cron scripts. There is also a security consideration as well.
Another thing to check is that you redirect both stdio and stderr.
The only thing I can think of is that whatever user is calling the scripts in cron.daily doesn't have permission to do some things. I made a script, test.sh, that contains the following:
#!/bin/bash
echo 'test `date` >> /var/log/test'
the file exists, but nothing gets written to it. Any suggestions?
Also, by full pathnames do you mean using /bin/echo instead of just echo?
Also, if cron does have an issue, it should/usually email the crontab owner (in this case root) with the problem/results. Login as root on the cmd line and use mailx or mail to check.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.