Crontab on hourly basis


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Crontab on hourly basis
# 1  
Old 02-01-2013
Crontab on hourly basis

Hi..

I need to run the script on hourly basis.
How do I write the crontab on hourly basis i.e, 9:00, 10:00.....22:00.. 23:00 hours

Please let me know if the below is correct one for crontab on hourly basis.
Code:
00 * * * * ksh myscript.ksh > /dev/null

Regards,
John
# 2  
Old 02-01-2013
It is correct.
# 3  
Old 02-01-2013
here is the small explaination.
Code:
1 2 3 4 5 /root/backup.sh
 Where,
¦1: Minute (0-59)
¦2: Hours (0-23)
¦3: Day (0-31)
¦4: Month (0-12 [12 == December])
¦5: Day of the week(0-7 [7 or 0 == sunday])
¦/path/to/command - Script or command name to schedule
Easy to remember format:
* * * * * command to be executed
- - - - -
| | | | |
| | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
| | | ------- Month (1 - 12)
| | --------- Day of month (1 - 31)
| ----------- Hour (0 - 23)
------------- Minute (0 - 59)
here a good comparison table i use to make it easy Format Meaning 
0 0 1 1 * Run once a year 
0 0 1 * * Run once a month 
0 0 * * 0 Run once a week 
0 0 * * * Run once a day 
0 * * * * Run once an hour

and
Code:
@yearly (or @annually) Run once a year, midnight, Jan. 1st 0 0 1 1 * 
@monthly Run once a month, midnight, first of month 0 0 1 * * 
@weekly Run once a week, midnight on Sunday 0 0 * * 0 
@daily Run once a day, midnight 0 0 * * * 
@hourly Run once an hour, beginning of hour 0 * * * * 
@reboot Run at startup @reboot

# 4  
Old 02-01-2013
Quote:
Originally Posted by scriptscript
How do I write the crontab on hourly basis i.e, 9:00, 10:00.....22:00.. 23:00 hours
If your requirement is to schedule your script to run each hour (24 times a day), then below setup is correct:
Code:
00 * * * * ksh myscript.ksh > /dev/null

But if you wan to run it only between 9:00 AM to 11:00 PM:
Code:
00 09-23 * * * ksh myscript.ksh > /dev/null

OR
Code:
00 09,10,11,12,13,14,15,16,17,18,19,20,21,22,23 * * * ksh myscript.ksh > /dev/null

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calculate avg response time on hourly basis

Hi, I am trying to calculate avg response time on hourly basis from the log file which has millions of records. As of now I am trying with creating temp file which will have lines with unique id and start time and end time and after that another script will run on this temp file to... (7 Replies)
Discussion started by: random_thoughts
7 Replies

2. Shell Programming and Scripting

Hourly averaging using Awk

Hey all, I have a set of 5-second data as shown below. I need to find an hourly average of this data. date co2 25/06/2011 08:04:00 8.30 25/06/2011 08:04:05 8.31 25/06/2011 08:04:10 8.32 25/06/2011 08:04:15 8.33 25/06/2011 08:04:20 ... (5 Replies)
Discussion started by: gd9629
5 Replies

3. Shell Programming and Scripting

FTP a file on Hourly basis

Hi, I have to upload a file test_201105281100.txt to a ftp location. The files will be created on hourly basis like test_201105281100.txt, test_201105281200.txt & so on. After a file is uploaded successfully, I need to rename the file as test_201105281100.success & if it is not uploaded... (11 Replies)
Discussion started by: SunilB2011
11 Replies

4. UNIX for Advanced & Expert Users

Problems with hourly removal in cron

In my cron job on one system I have log files removed older than 3 days, like so: find /u01/arch/PRD8 -mtime +3 -a -name "*.log" -exec rm {} \; On another system I would like to check and remove anything older than 2 hours. Any help would be greatly appreciated :wall: (7 Replies)
Discussion started by: georgia
7 Replies

5. Shell Programming and Scripting

how to grep string from hourly basis files

dear all, pls help on this script.. i have many files which will be created every mins in particular directory. i want to grep a particular string from only for unique hour files. from the below code i want to grep a string from only 9th hour files . Ex files: -rw-r--r-- 1 root ... (5 Replies)
Discussion started by: steve2216
5 Replies

6. UNIX for Dummies Questions & Answers

Maintaining HOURLY backups

I have a system where i take hourly back-ups of the system.The script for maintaining full backup for the last 5 days is find /backup/server -type f -mtime +4 -exec rm -f {} \; works fine for keeping the files of some 5 days old. In the case of hourly backups.How do we write to keep... (2 Replies)
Discussion started by: ravi55055
2 Replies

7. Solaris

Monitoring the output of 'top' command on hourly basis.

I need to capture the following data on an hourly basis through cronjob scheduling:- 1. load averages 2. Total no. of processes. 3. CPU state 4. Memory 5. Top 3 process details. All the above information is available through the command 'top'. But here we need to automate the same and... (4 Replies)
Discussion started by: subharai
4 Replies

8. Red Hat

hourly kannel log rotation

I need to Change threshold of rotation of kannel logs. At the moment, Kannel (the SMS gateway system) logs activities in log files which are rotated daily. Due to high traffic, the logs grow fast every day before they are rotated; meaning that the write speeds while logging slow down due to large... (2 Replies)
Discussion started by: Targ
2 Replies

9. UNIX for Dummies Questions & Answers

How do you automate an hourly file check?

Hi, New to the forum, Great site, I can learn a lot from here!! :cool: I would like to know how to automate a command that checks the Sybase database's are "alive" on an hourly basis, and mails outlook if they are not (1 Reply)
Discussion started by: mals
1 Replies
Login or Register to Ask a Question