Edit a crontab in Linux

Cron is a great feature which can allow you perform tasks on a scheduled basis. For example, if one wanted to execute some script, each night a midnight one would need to edit their crontab file in linux to and instruct it to schedule the task. To edit a crontab file perform:

[root@computer ~]# crontab -e

The -e parameter is for edit. An example of a crontab entry is:

0 0 * * * /usr/local/bin/some_script.pl

The entry above executes some_script.pl every night at midnight. If no crontab exists when editing the file for the first time, one will be created.

Also, your default editor is used when editing the crontab file. If you wish to change it the following can be set:

export EDITOR=vi

This will instruct crontab to utilize the vi editor.

If for whatever reason you need access directly to the crontab file, it is located at


However, editing crontabs this way is not recommended.

If you would like to list the contents of a crontab simply perform:

crontab -l

Editing crontab is easy and has a lot of options. Be sure to use this great linux tool when building your infrastructure.

Be the first to comment

Leave a Reply