How to run crontab job every minute on a Linux or Unix-like system

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:

  1. Open a terminal or shell prompt.
  2. Type crontab -e to open the crontab in the default editor.
  3. 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.

  4. 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.

Leave a Comment