Task Scheduling in Linux with cron

Cron is a Linux and UNIX based tool that allows scheduling automated tasks.

Cron commands are stored in a file named for the user who created them in /var/spool/cron/

CRON Commands

The Crontab command is used to create new cron files:

  • Crontab -l list the contents of your personal cron file.
  • Crontab -r removes all crontab entries.
  • Crontab -e opens your default text editor for cron job creation.
SYNTAX

Steps Creating a Cron Job

  • Login to your server as root
  • Create a directory for the purpose of testing as
mkdir /crondemo
  • Add files to the crondemo directory using touch command
touch file1 file2 file3 file4 file5
  • Open crontab -e and add the command
SYNTAX 1

Allow sometime and list the directory once the cronjob runs.

SYNTAX 2

We hope you’ve found this useful! 

Leave a Comment

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