Schedule a cronjob on ssh with command line
Solution 1
As @The.Anti.9 noted, this kind of question fits in Serverfault. To answer your question, crontab is a little more powerful than 'at' and gives you more flexibility as you can run the job repeatedly for instance daily, weekly, monthly.
For instance for your example, if you need to run the script every day at 18:30 you'd do this,
$ crontab -e
then add the following
30 18 * * * /path/to/your/script.sh
save and you are done.
Note: 30 18 indicates time 18:30, and *s indicate that it should run every day of every month) If you need to run it on a particular day of the month just check it out on the man page of crontab.
Solution 2
Doesn't crontab -e work? and to generate crontab code http://www.openjs.com/scripts/jslibrary/demos/crontab.php should help.
gaurav
Updated on June 14, 2022Comments
-
gaurav almost 2 years
I am using the amazonaws es3 server.I want to schedule my cron with command line. I am using the this command for scheduling the cron job
at -f shellscript.sh -v 18:30
but it will schedule for only one time i want to configure manually like once a day or every five minutes .
Please help with command which command i have to used
Thnaks,
-
veritaS over 5 yearswhat do I do, if I want it to run at several specific times a day e.g. 9:00, 12:00 and 18:30 o'clock ? create 3 cronjobs or can I specify it in one?
-
Kibet Yegon over 5 years@veritaS If the time duration between them is the same (say every hour) then one crontab is sufficient. If its not like your case, you'd need to have 3 entries. Check the crontab manpage or use this generator
-
veritaS over 5 yearsI currently have it running with comma seperated values. You can do something like 30 5,11,18 * * * /path/to/your/script.sh which translates to at 5:30, 11:30 and18:30