Problem with CRON Help..
Hi everybody..I'm a newbie of this cron...
I already have a crontab but the cron is not executing the schedule.. I don't what are those things need to consider in order for the cron to run perfectly.. is there configuration,package need to install before to use this cron...please help.. |
If you have a crontab, all the needed software should be there. Is the cron daemon running?
Code:
/etc/init.d/crond status |
Quote:
0 * * * * cd /home/lotw/public_html/MOTD; make is there any configuration need to setup? cause I see many crontab. I'm just wondering how the system execute this files and what is the contrab being executed first. |
Linux usually has a system crontab /etc/crontab to run jobs on a hourly, daily, weekly and monthly basis. In addition every user has its own crontab (that one you edit using crontab -e) and everyone is allowed to have it, unless the username is listed in /etc/cron.deny. Regarding the crontab being executed first, the order is that one dictated by the time specification in the crontab itself. It's the cron daemon that takes care of doing things in chronological sequence.
Regarding your issue you need to check: 1. if the cron daemon is running 2. if your username is listed in /etc/cron.deny 3. if the system logs (e.g. /var/log/cron) report your cron job running at the specified time 4. if there is some message from the cron daemon in your mail box (use the mail command). |
Quote:
for step No. 1, I check the status of the crond, and it says that it is running. for step No. 2, there is no cron.deny exist in the system but instead of cron.d.. I guess its the same, and when i open the directory there is no "root" in the list. for step No. 3, I don't exactly understand on how to do this step..but i try to open the example directory, but it seems the directory is not exist. and for the last step, I type mail on the CLI and it says that "No mail for root". I think I have problem with the step 3. |
Depending on your Linux OS (which is it?) you might not have the /var/log/cron file. As root you can do:
Code:
grep -E -i "CROND|CMD" /var/log/* Code:
# tail /var/log/cron Code:
0 13 * * * /home/skiron/download_skiron.sh $(date +\%Y\%m\%d) |
Quote:
Sep 11 05:00:01 host crond[13526]: (root) CMD (cd /home/lotw/public_html/MOTD; make) and the latest is Sep 13 20:00:01 host2 crond[8430]: (root) CMD (cd /home/lotw/public_html/MOTD; make) is it good or bad? |
It's good. At least the cron job is executed. Now you should check where the problem is and try to catch the standard output and the standard error from the job. Try to redirect them to a file so that you can check it later:
Code:
0 * * * * cd /home/lotw/public_html/MOTD; make >> /root/crontab.log 2>&1 |
Quote:
But i have some weird stuff happen here..The command in the crontab is perfectly working when i tried to copy and paste it on the CLI... do you have any idea about this sir..? Is there a way to upgrade and downgrade the nice command? |
Quote:
Code:
#!/bin/bash -l Code:
0 * * * * bash -l /path/to/my_script.sh Quote:
|
Quote:
Code:
0 * * * * cd /home/lotw/public_html/MOTD; make >> /root/crontab.log 2>&1 That is the weird thing. The cron is executing the same command that i used to type on the CLI, but it is getting an error, the error is: Code:
make: *** No rule to make target `31 Aug 2021 test3.mp3', needed by `mp3'. Stop. I'm just wondering if it is the version of daemon or something like that. Cause I have two different server running the same application. The old server is executing the command perfectly, even it is executed by cron or typed it manually on the CLI, overall it is fine working. But on the new server it turns me the error above. How to determine the version of daemon? |
To find out which version of the cron daemon you have, you can try to determine which package owns the /usr/sbin/crond executable. On a RPM based system you can try
Code:
rpm -qf /usr/sbin/crond Code:
dpkg -S /usr/sbin/crond I still suggest to put the command line in a script and execute it by means of bash -l to see if it is a problem with the login environment. |
Quote:
I try to execute the command from a bash file, and it is working..no error. |
Quote:
|
Quote:
Code:
0 * * * * cd /home/lotw/public_html/MOTD; path/of/make >> /root/crontab.log 2>&1 |
All times are GMT -5. The time now is 12:47 AM. |