[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 512
  • Last Modified:

Need help with a few Crontab entries

I need a few crontab entries to run a script :
1. Every hour, on the hour
2. Every hour, 15 mins past the hour
3. Every hour, half past the hour
4. Every 15 mins
5. Every 22 mins
0
TotallyMe
Asked:
TotallyMe
1 Solution
 
woolmilkporcCommented:
Hi,
a crontab entry basically takes the format
minute hour day-of-month month day-of-week command
(with an asterisk defining all values, from lowest to highest)

1) 0 * * * * [command]
2) 15 * * * * [command]
3) 30 * * * * [command]
4) 0,15,30,45 * * * * [command]
5) impossible, as 22 is not evely divisible by 60. Nearest approach
0,22,44 * * * * [command]
For 4), there are other notations, but not in all Unixes
I put an asterisk for the values (day-of-month, month, day-of-week)you didn't mention in your Q.
HTH
wmp
 
0
 
omarfaridCommented:
here we are:

1- 0 * * * * /path/to/script
2- 0/15 0 * * * /path/to/script
3- 30 * * * * /path/to/script
4- same as 2
5- 0,22,44 * * * *  /path/to/script
0
 
omarfaridCommented:
correction:

2- 15 0 * * * /path/to/script
4- 0/15 0 * * * /path/to/script

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ifreqCommented:
0
 
Hugh FraserConsultantCommented:
5. I've had a similar problem in the past, and used the "at" command to re-schedule a script to run at intervals that are not evenly divisible into 60 minutes (like every 22 minutes). The first thing the script does is re-schedule itself in another 22 minutes. The trick is that current time can't be used to determine the next run time, since the job might be delayed on a busy system.

I addressed this by including the scheduled time as an argument to the job, and some simple perl code to re-submit itself based upon the value.
0
 
Monis MontherSystem ArchitectCommented:
Hi

Check the crons from Omar Farid first post above with a simple correction on:

2/     15 * * * * /path/to/script       this runs every  hour +15 minutes like 1:15, 2:15 , 3:15...etc
4/     */15 * * * *  /path/to/script    this runs every 15 minutes
0
 
woolmilkporcCommented:
Please remember that the '*/n' syntax is not supported at least in AIX, HPUX, Solaris and most of the remaining commercial Unixes!
0
 
omarfaridCommented:
woolmilkporc is correct about the syntax , but since this is under linux zone assumption is made that it is linux platform which supports this format
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now