Centos 6 Cron not working

Sigma721

Well-Known Member
Joined
Sep 14, 2011
Messages
122
Reaction score
0
Hi everyone

I am trying to get a script to run every 5minutes using Cronjob. I have read everything I can find on the topic, but cannot seem to get it working.

I have tried adding the following line to the /etc/crontab file using nano text editor and also tried using crontab -e.

2 * * * * root /bin/bash /home/ads/nameChanger.sh > /home/ads/logs/cron.log

Nothing happens though, the script does not run, nor does a log file get updated.

Any suggestions?
 
Are you adding this to the root users crontab?

Firstly you don't need to include the user and shell path, secondly you should make sure that your script is executable, thirdly you should use double >> if you want to append instead of overwriting the log everytime.

Your above cron will run at 2 minutes past every hour, every day.

As above you could just use:

Code:
chmod +x /home/ads/nameChanger.sh

then,

Code:
crontab -e -u root

then,

Code:
2 * * * * /home/ads/nameChanger.sh >> /home/ads/logs/cron.log

Hope this helps.

EDIT: Just a reminder, you should try to not run your scripts as root. This can be very dangerous.
 
Last edited:
Thanks a lot, its working now!

*/5 * * * * /home/ads/nameChanger.sh >> /home/ads/logs/cron.log

I changed it a bit so it runs every 5 minutes, not only x minutes past the hour.



Thanks again
 
Top
Sign up to the MyBroadband newsletter
X