How to setup a scheduled task in Ubuntu
i need to setup a scheduled task to automatically run the following command every hour:
perl '/myscripts/script.pl'
Any help is very appreciated
Thanks
Sal
7 Replies
As the user that you want to run the command as you would run:
crontab -e
This will bring up an editor. Put the following in the editor and save it.
0 * * * * perl '/myscripts/script.pl'
This will run the command ever hour at 0 minutes of that hour.
–Sean
Sal
even if the task has been added to the edited crontab file, it is not running.
I have verified that the command i have added is correct by running it in terminal and it works, but i don't know what i can do to let the cron run by itself.
I see that when i run the crontab -e command it opens a file named "crontab" which contains the command i have added before, but i'm not sure if it has been saved in the right location, because if i open the file /etc/crontab it does not contain the command i have added.
Thank You
Sal
Try 'crontab -l' to list your user cron file. Using 'crontab -e' should create copy of what is in /var/spool/cron/crontab, and, when you save, put it back in place. You should see a message in the console "crontab: installing new crontab", and, if you look in /var/log/cron.log, a sequence like this:
Jun 24 13:06:28 speedy crontab[11270]: (steveg) BEGIN EDIT (steveg)
Jun 24 13:06:35 speedy crontab[11270]: (steveg) REPLACE (steveg)
Jun 24 13:06:35 speedy crontab[11270]: (steveg) END EDIT (steveg)
Jun 24 13:07:01 speedy /usr/sbin/cron[2833]: (steveg) RELOAD (crontabs/steveg)
If there's a problem, you should see an error message.
i have done 'crontab -l' and verified that cron job has been added to that file, but i don't see the cron.log inside the /var/log/ , so i think there is something wrong with cron on my ubuntu installation.
Is there some command i can run to force cron to start?
Thank You
Sal
Thank You
Sal