To run a crontab job every minute on a Linux or Unix-like system, you can use the following syntax:
* * * * * command-to-be-executed
This will run the command-to-be-executed
every minute of every hour of every day of the week.
Here’s a breakdown of what each *
represents:
*
in the first field represents the minute*
in the second field represents the hour*
in the third field represents the day of the month*
in the fourth field represents the month*
in the fifth field represents the day of the week
So when you use *
in all five fields, it means that the job will run every minute of every hour of every day of the month, every month, and every day of the week.
To add a job to the crontab, follow these steps:
- Open a terminal or shell prompt.
- Type
crontab -e
to open the crontab in the default editor. - Add the following line to the crontab file:
* * * * * command-to-be-executed
Replace
command-to-be-executed
with the command that you want to run every minute. - Save the changes and exit the editor.
The job will now run every minute. You can verify that it is running by checking the logs or the output of the command that is being executed.