• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to run a cron job on specific days of the week

by admin

Question: How to run a cronjob on a specific day of the week or a range of days of the week?

To run a cron job on specific days of the week, you can specify this via the following:

1. Edit the crontab for the user wishes to create the crontab job for. For example:

# crontab -e

Then add an entry specifying the date and time and day of the week you wish to run the crontab job on. For example:

This crontab entry runs the script at 17:00 (5PM) on Saturdays:

0 17 * * 6 /script/script.sh

This crontab entry runs the script at 17:00 (5PM) on Sunday through to Friday:

0 17 * * 0-5 /script/script.sh

2. There’s more detail on the different crontab options in the man pages, specifically:

# man 5 crontab

3. However, days of the week can be specified in the rightmost number in the above examples with values of 0 to 7 representing each day of the week and Sunday being able to specified by either 0 or 7.

Filed Under: Linux

Some more articles you might also be interested in …

  1. keyctl Command Examples in Linux
  2. datamash: command not found
  3. postfix: command not found
  4. lvmconf Command Examples in Linux
  5. whois Command Examples in Linux
  6. How To Execute The Pstack Command On CentOS/RHEL
  7. losetup: command not found
  8. openfortivpn: command not found
  9. How to Setup SSH keys for SSH “public/private key” Login On Linux
  10. How to use Exit Codes in Conditional Statements in Shell Scripts

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright