/etc/cron.d folder doesn’t work in centos 5.3
| July 9th, 2010In centos, if you dont want to use the default crontab you can create your own scheduler.
The options are
- Create a crontab by crontab -e
- Create your crontab in a file and put it in /etc/cron.d folder
I choosed option 2 because from my opinion, putting your crontab in a file is more manageable and looks more prettier. For example i can create multiple crontabs that run using multiple user level in the file instead of login to every user and create crontab for each user.
So i created a file called myCrontab and put
0-59 * * * * /home/myuser/test.sh > /home/myuser/test.log
This will execute test.sh every minute, and in test.sh i have
echo “Hell0W0rld at $(date)”
But nothing happened in the test.log.
When i tried to put 0-59 * * * * /home/myuser/test.sh > /home/myuser/test.log in my user crontab using crontab -e, it worked!
After googling, i found some advices like to remove blank line at above my scrpt if any, or chmod 644 myCrontab instead of chmod 755.
But still not worked, until i found in a forum that if you use /etc/cron.d folder you have to put your user in the crontab script.
So i changed myCrontab file to
0-59 * * * * root /home/myuser/test.sh > /home/myuser/test.log
and it works well !!!



