How to Set Cron Settings

How to Set Cron Settings thumbnail
Cron can be used to organize computer tasks by running them at user-specified times.

Cron is a job scheduler for Unix-like operating systems, including Linux. Cron allows a user to automate computer tasks by entering commands in cron that call commands, such as a user-written script or a general program, at specific times. Cron is an easy-to-use program, and specific cron settings, such as when to call a function or who has permission to modify a command, are relatively straightforward.

Things You'll Need

  • Computer with Unix-like operating system.
Show More

Instructions

    • 1

      Open the crontab editor. This allows you to edit the commands that the cron program will read and run. This editor can be opened using the command:

      crontab -e

    • 2

      Decide when you would like your program to run. There are five fields to specify, which are: minute, which is a value from 0 to 59; hour, which is a number from 0 to 23; day of month, which is a number from 1 to 31; month, which is a number from 1 to 12; and day of week, which is a number between 0 and 6, where 0 represents Sunday.

      For example, if you would like your program to run at 6:30 am every Monday, as well as the 7th day of every month, the entry would look like:

      30 6 7 * 1

    • 3

      Enter the command you would like to run immediately after the fields. For example, if you would like to run a shell script called "script", located in your home folder, the crontab editor would look like the following:

      30 6 7 * 1 bash ~/script

Tips & Warnings

  • If you would like cron to call the command at every possible value of the field, use *. For example, in the "hour" field, entering * will call the program at every possible hour, 0 to 23.

  • To see the cron settings for different users, enter the command "crontab -u user", where "user" is the settings for whom you want to see.

  • The crontab can be opened in a number of different text editor, including vim, pico and others. Ensure you understand the basic syntax of the editor you are using.

Related Searches:

References

Resources

  • Photo Credit Jupiterimages/Comstock/Getty Images

Comments

Related Ads

Featured