Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup a crontab to execute at specific time

Tags:

cron

settings

How can I set up my crontab to execute X script at 11:59PM every day without emailing me or creating any logs?

Right now my crontab looks something like this

@daily /path/to/script.sh
like image 528
DylanJ Avatar asked Aug 06 '08 07:08

DylanJ


People also ask

What is the use of * * * * * In cron?

It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .

How do you change the time of a cron job?

If your system uses log rotate, then older logs will have a timestamp appended; for example “cron-20170522”. To verify, just open the cron log file and search for “ ntpdate ”, and you should see that the command is run by the root user. Hopefully, this helps someone that needs to run a scheduled command or script.


1 Answers

When you do crontab -e, try this:

59 23 * * * /usr/sbin/myscript > /dev/null

That means: At 59 Minutes and 23 Hours on every day (*) on every month on every weekday, execute myscript.

See man crontab for some more info and examples.

like image 100
Michael Stum Avatar answered Oct 02 '22 12:10

Michael Stum