Thursday, April 7, 2022

Linux Cron jobs

 Cron jobs

It is a software utility that is a time-based job scheduler in Linux. With the help of this utility, you can run commands or scripts at a given date and time.We can schedule the jobs like taking backups or move the files etc periodically with the help of cron jobs

Setup Cron jobs

Step 1: Update the apt repository

            apt update

Step 2: Check cron is already installed or not (on Ubuntu)

        dpkg -l cron

Step 3: If it is not installed then install it

      apt install cron -y

Step 4: Check the service is in a running state or not

     systemctl status cron

Step 5: create a file /home/vagrant/

      add below content

     echo `date` >> /home/vagrant/file1

Step 6: Provide execute permission to your file

     chmod 777

Step 7: Run the below command to setup the cron job.

    crontab -e

add below entry at the bottom

  * * * * * /home/

Step 6: Wait for 1 min and you will find that script is executed


Post a Comment