There are fields on my server's control panel like this
Minute - Hour - Day of month - Month - Day of the week - Command
How can I create a cron job runs on first day of the month with this fields?
There are fields on my server's control panel like this
Minute - Hour - Day of month - Month - Day of the week - Command
How can I create a cron job runs on first day of the month with this fields?
This will run the command foo at 12:00AM on the first of every month
0 0 1 * * /usr/bin/foo
This article describes the various fields, look to the bottom of the page: http://en.wikipedia.org/wiki/Cron
To add this to your cron file, just use the command
crontab -e
0 0 1 * ? though my Vixie cron on Ubuntu 14 LTS refuses them
– Marco Marsala
Sep 16 '16 at 13:16
crontab -e because it write the cron according to the current user than crontab command.
– Francesco
Mar 28 '17 at 07:03
Will run /usr/bin/foo at 12:10am on the first day of the month.
10 0 1 * * /usr/bin/foo
Will run /usr/bin/foo at 3:10am on every day.
10 3 * * * /usr/bin/foo
See http://www.scrounge.org/linux/cron.html
updated the crons, it was a copy paste error, thanks Joy Dutta!
10 3 * * * /usr/bin/foo
12:10am on first day of month is 10 * 1 * * /usr/bin/foo
–
Nov 23 '09 at 17:37
0 0 1 * ?, though my Vixie cron on Ubuntu 14 LTS refuses them
– Marco Marsala
Sep 16 '16 at 13:21
use following:
@monthly /home/user/backup.sh
more information:
man 5 crontab (files used to schedule the execution of programs)Check for a directory on your server at /etc/cron.monthly. If the directory exists, odds are your system is set up to run any executables it finds in that folder on a monthly basis. Just drop your script (or symlink it) in /etc/cron.monthly. Also, make sure your script is executable.
Something like:
0 0 1 * * command /directory/file.ext