PDA

View Full Version : help needed to set up a cronjob



J_Me
December 16th, 2013, 02:49 PM
Could someone please help me out. My bash file looks like this
#!/bin/bash foo I've made it executable with
chmod +x fooand now I have to put it in my crontab with
* 1 * * * /home/me/myscripts/foo which should run this bash file at 1am each day. I read that I should run 'crontab -e' but doing this opens an empty file but my /etc/crontab file is not empty. Thanks

r-senior
December 16th, 2013, 03:03 PM
The /etc/crontab file is the system crontab. It won't be empty because, on Ubuntu at least, it fires off other cron jobs from /etc/cron.daily/ and so on. These do all sorts of things: checking for updates, rotating log files, etc. The system crontab is edited directly, not with crontab -e, but you probably don't want to edit it.

Each user has their own crontab which is edited by using crontab -e. The first time you use crontab -e it will be empty. This is where you should put your jobs. The files it creates are stored for each user in /var/spool/cron/crontabs/<username> but you shouldn't edit these directly. Always use crontab -e to edit and crontab -l to view.

Note that if you use sudo crontab -e, you edit the crontab for the root user, not the system crontab in /etc/crontab.

J_Me
December 16th, 2013, 03:13 PM
Thank you very much for your detailed explanation.

Habitual
December 16th, 2013, 04:59 PM
* 1 * * * /home/me/myscripts/foo which should run this bash file at 1am each day.

1am and 60 times for every minute in that hour.


00 1 * * *

http://www.dataphyx.com/cronsandbox/cronsandboxgui.php

ivan19
December 20th, 2013, 02:17 AM
try using "The EasyCronjobHandler" http://codecanyon.net/item/the-easycronjobhandler/6296537