Wednesday, February 22, 2023

What is the syntax for scheduling a crontab job to run every 2 minutes?

Crontab is an incredibly useful and powerful tool for scheduling tasks in Linux systems. It allows administrators to set up automated tasks, such as background processes, maintenance jobs and other system-level activities on a regular schedule. But, what if you need to run a certain task every two minutes? How do you set up the crontab syntax for that?

The syntax for scheduling a crontab job to run every two minutes is quite simple. First, you need to open the Crontab. To do so, enter the command: crontab -e

This will open the cron table editor in your terminal window. The first line of the file defines what timezone is used by the system's scheduler. You should leave this line as it is since it's already set up correctly.

To schedule a job to run every two minutes put this line at the end of the file:

*/2 * * * * /path/to/command

The above line defines that a certain command will run every two minutes (the asterisk (*) denotes all applicable values). However, if you want to specify different times, like running something at 14:20 every day, here is how it would look like; 20 14 * * * /path/to/command

Then, save and close the file with ctrl+x followed by y. This will apply your new settings and start running your jobs according to your desired schedule.

See more about crontab every 2 minutes

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.