How to do it...

  1. Open your terminal and go to the /etc folder and check the /cron folders. You will see the following cron folders:
    • /etc/cron.hourly
    • /etc/cron.daily
    • /etc/cron.weekly
    • /etc/cron.monthly
  2. Now, we will copy our shell script into one the preceding folders. 
  3. If you need to run your shell script to run daily, place it in the cron.daily folder. If you need to run it hourly, place it in the cron.hourly folder, and so on.
  4. Example: Write a script and place it in the cron.daily folder. Make the script executable by giving the necessary permissions.
  5. Now, run the crontab command:
$ crontab -e
  1. Press Enter and it will ask for the editor of your type. By default, it will open vi editor. In my case, I selected nano. Now, create a cron ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.