Script is not running in Crontab
I have scheduled a script in crontab for every minute with all ***** stars but this script is not running , manually i am able to run the same script successfully , i am running in the same shell that is used in my script.
CMD execution can be shown in logs of cron but crontab is not executing as per the scheduled time. please suggest |
If you have to run something every minute, then I suggest writing the minute-loop into the script itself. Have the script take care of the timing.
|
i have not included minute loop in the script but i tried to write the simple hello word program also and scheduled in cron for every min that is also not working for me:(
do i need to route the o/p of script on some terminal explicitly? , can you please cite an example for successful hello world script that runs in every min via cron? |
Perhaps cron runs the command only every after a minute after the script has finished executing, so that means it's not going to run exactly a minute after each start time. If there's no other way to configure that properly in cron, perhaps it would really be best if you run a daemon script that would execute the command every minute.
As an example: Code:
#!/bin/bash Code:
#!/bin/bash |
Can you show the entry in the crontab?
|
Hi,
Try debug this by redirecting the cron output to a file Code:
* * * * * /path/to/script/script.sh 2>&1 >> /tmp/logfile.txt |
And check /var/log/syslog to see if your script ran at all or not.
Did you put an empty line as last line in crontab? jlinkels |
iamwilliam's technique is a good idea. As hinted, cron runs in a restricted environment, so always use the full path to any cmd or file or supply the relevant PATH etc yourself explicitly in the code.
Also, add Code:
set -xv Note also that cron is a detached process, ie has no cxn to any terminal sessions |
Btw, if you are to run a deamon, it's best if you just use another higher language instead, just to save IO binary read/syscalls. Like Perl, Python or Ruby.
|
All times are GMT -5. The time now is 06:03 PM. |