March 2, 2019

On Linux servers, cron can be used to schedule jobs that run commands and shell scripts at fixed times, dates or intervals. It’s great for repetitive tasks like backups, downloads and deleting log files. See

Cron Editor

Cron jobs are configured by crontab files that are stored where the cron service is located.  Use just about any Linux console text editor to manage these crontab files. Here’s how to use the Nano text editor in a one-time session or as the default crontab editor.

Set Nano as the default crontab editor (session only)

Run export command to set the default editor
export VISUAL=nano

Set Nano as the default crontab editor (permanently)

Change to user’s home directory and edit environment settings (CentOS)
nano .bashrc

# User specific aliases and functions
export VISUAL=nano

Activate environmental PATH variables and confirm they show up in the path
source ~/.bashrc

Cron Commands


Each line in the crontab file represents a scheduled job, with the following parameters. An asterisk is used as a placeholder for an unused date parameter.

  • m: minute the command executes on, between 0 and 59.
  • h: hour the command executes on, between 0 and 23.
  • dom: day of month the command executes on.
  • mon: the month the command executes on, between 1 and 12.
  • dow: the day of the week the command executes on, between 0 and 7. Sunday may be specified by using 0 or 7, both values are valid.
  • command: the command to execute.
# m h dom mon dow   command
0 11 * * * /home/backups/ 

sudo systemctl status crond

crontab -l

crontab -e

Check for cron error messages
cat /var/spool/mail/semaphore

Check cron log for history
cat /home/semaphore/backups/cron.log


  • Make sure file ends with an empty line!
  • SELinux – sudo setenforce 0


Clear log files

This example has three jobs. Each job runs a different shell script, silences cron error messages and then appends any remaining output to a specific log file.

> is for redirect
/dev/null is a black hole for data
2 is the file descriptor for Standard Error (STDERR)
>> append to file

01 01 * * * /home/saf/logs/ > /dev/null 2 >> /home/saf/logs/cron.log
01 01 * * * /home/saf/logs/ > /dev/null 2 >> /home/saf/logs/cron.log
01 01 * * * /home/saf/logs/ > /dev/null 2 >> /home/saf/logs/cron.log

Leave a Reply

Your email address will not be published. Required fields are marked *