Scripts in the crontab not running on the scheduled time
Linux - EnterpriseThis forum is for all items relating to using Linux in the Enterprise.
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.
The request by custangro is wise, since if we can see the content of the script (unless it is an X-file) we can have a clue of the issue which prevents the execution from crontab. A typical recommendation is to use absolute paths for the commands within the script, because the crontab runs with a very limited environment and the PATH is usually limited to /bin:/usr/bin. Also in a crontab entry you have to follow some rules about special characters: for example the percent sign %, if written in a crontab, has a special meaning and you have to escape it in order to get the expected behaviour.
So if you show us the actual crontab and the content of the script, we can be more helpful.
Below is a crontab that is on Linux 64 bit machine and similarly i have scheduled the crontab on solaris machines also. But only the bewlow script doesn't runs on any machine.
Here is the script that is causing problem.
scripts starts from here:-
#!/usr/bin/ksh
echo "##############################################"
echo "###### Starting new reporting ################"
date
rm /gfs/wlv/colfax/d1/local/XXX/hptolemy/test/scripts/logs/logs-Linux-46-colfax/*.xml
The last script start_dsdiff_report_gen_autosim1_cfx_cl_pista
is causing problem. This is a report generation script. It doesn't runs at the scheduled time.
And sorry but i haven't checked for this question. **Also, have you checked /var/log/cron for messages generated around the time that the script is supposed to run?**
I am not aware of the above question. Please let me know what is the answer.
Regards,
Ajay
Last edited by shajay12; 02-20-2009 at 12:25 PM.
Reason: wanted to confirm
Try to put full paths of the commands within the script: /usr/bin/perl in place of perl, /bin/date in place of date and so on. This is a general rule for crontab scripts, since the PATH of cron is limited in respect of the PATH available to the shell.
Moreover, since you did not redirect the standard error and/or the standard output of the last job, try to see if the owner of the crontab received a mail with some clarifying message. By default stderr and stdout are sent by mail, that one you can see using the command mail from a terminal. If something is wrong, you will find some message from the cron daemon there.
Doesn't it run or does it abort at a very early stage? You can check the file /var/log/cron to see if the cron daemon actually run the script at the scheduled time or if it just ignored it. For example, you should see an entry like this:
Code:
Feb 22 19:00:01 ocean-4 crond[342]: (shajay) CMD (ksh /hfs/di/local/XXX/hptolemy/test/scripts/start_dsdiff_report_gen_autosim1_cfx_cl_pista)
Also check the system mail of the owner of the crontab. If the script actually runs, all the generated standard output and standard error is sent to the user by mail (if not redirected to a file).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.