Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add 10 minute cron job to Ubuntu package [closed]

I need to install some cron jobs with my Ubuntu installation package. The ones that run every day or hour are easy: I can just create a symlink from /etc/cron.daily to my script.

However, I also have a script that I would like to run every 10 minutes. There is no such thing as /etc/cron.minutely. Also I am not sure how to edit crontab without using the interactive editor (crontab -e). What is the best way to go about this?

like image 883
Jeroen Ooms Avatar asked Apr 23 '12 23:04

Jeroen Ooms


People also ask

How do I schedule a cron job every 10 minutes?

Run a Cron Job after every 10 minutes The slash operator helps in writing the easy syntax for running a Cron job after every 10 minutes. In this command, */10 will create a list of minutes after every 10 minutes.

Do cron jobs run when terminal is closed?

Show activity on this post. When your computer is shut down (or the cron daemon is otherwise not running), cron jobs will not be started. If you have jobs that you would like to run after the fact during those times when the computer is shut down, use anacron.

How do I run a cron job every 5 minutes?

basic 3. /usr/bin/vim. tiny 4. /bin/ed Choose 1-4 [1]: Make a new line at the bottom of this file and insert the following code. Of course, replace our example script with the command or script you wish to execute, but keep the */5 * * * * part as that is what tells cron to execute our job every 5 minutes.


1 Answers

Your package can simply put a file in /etc/cron.d/

The text file should contain something like this, to run a command every 10 minutes:

*/10 * * * * root /path/to/command

Google 'cron format' for more info, and yes, this belongs in askubuntu or superuser.

You need to add the username (root) to the line, as shown above. Apparently this is necessary for files in cron.d, but I can't find a definitive document.**

cron should pick this new job up automatically.

like image 86
laher Avatar answered Sep 21 '22 17:09

laher