Reading a crontab 3 * * 1,3,5 /path/of/script.sh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading a crontab 3 * * 1,3,5 /path/of/script.sh
# 1  
Old 11-13-2012
Reading a crontab 3 * * 1,3,5 /path/of/script.sh

Hi!

We are on AIX 6.1 TL6

I am an Admin for a Content Management application that is hosted on an AIX machine and i am supposed to come up with a cronjob that runs every monday at 03:00 am.

The current schedule of that cron job is :
Code:
3 * * 1,3,5 /path/of/script.sh

But i do not know how to understand this

Can someone tell me what that schedule means and what must it be changed to for running every Monday.

Thanks!

Last edited by Franklin52; 11-15-2012 at 03:59 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 11-13-2012
Shouldn't it be :

Code:
0 3 * * 1 /path/script.sh

instead ?

Code:
man crontab

Code:
man cron

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 11-13-2012
This means:

0 min/ of the 3rd hour/ of every day / every hour / Monday

Am i correct ?

Quote:
Originally Posted by ctsgnb
Shouldn't it be :

Code:
0 3 * * 1 /path/script.sh

instead ?

Code:
man crontab

Code:
man cron

# 4  
Old 11-13-2012
From the man page for crontab on AIX 6.1:

Code:
The crontab File Entry Format

       A crontab file contains entries for each cron job. Entries are separated by newline characters. Each crontab file entry contains six fields
       separated by spaces or tabs in the following form:

       minute  hour  day_of_month  month  weekday  command

       These fields accept the following values:
       minute
            0 through 59
       hour
            0 through 23
       day_of_month
            1 through 31
       month
            1 through 12
       weekday
            0 through 6 for Sunday through Saturday
       command
            a shell command

---------- Post updated at 03:38 PM ---------- Previous update was at 03:36 PM ----------

So with ctsgnb correction, you have 3am every Monday.
This User Gave Thanks to in2nix4life For This Post:
# 5  
Old 11-13-2012
Thank you!

I also have another question, but i dont know if i must open a new thread.

In the crontab, i need to include shutdown command and also the start up command in the following order

This should run first - 0 3 * * 1 /path/shut_down_first.sh
This should run after the above one - 0 3 * * 1 /path/start.sh

The idea is...the service must be shutdown and restarted every monday at 3 am.

Can you help me with this ?

Thanks a ton!




Quote:
Originally Posted by in2nix4life
From the man page for crontab on AIX 6.1:

Code:
The crontab File Entry Format

       A crontab file contains entries for each cron job. Entries are separated by newline characters. Each crontab file entry contains six fields
       separated by spaces or tabs in the following form:

       minute  hour  day_of_month  month  weekday  command

       These fields accept the following values:
       minute
            0 through 59
       hour
            0 through 23
       day_of_month
            1 through 31
       month
            1 through 12
       weekday
            0 through 6 for Sunday through Saturday
       command
            a shell command

---------- Post updated at 03:38 PM ---------- Previous update was at 03:36 PM ----------

So with ctsgnb correction, you have 3am every Monday.
# 6  
Old 11-13-2012
Code:
0 3 * * 1 /path/shut_down_first.sh && /path/start.sh

or if want to do more elaborate checks between the shutDown and the startUp steps, implement a bounce.sh script and do it all there.
This User Gave Thanks to vgersh99 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

2. Shell Programming and Scripting

Grep script name with path from crontab

I need help to grep file name with path from crontab ex : 0 5 * * * /tmp/test.sh 2>/tmp/test.log output : /tmp/test.sh Please use code tags next time for your code and data. Thanks (6 Replies)
Discussion started by: jhonnyrip
6 Replies

3. Red Hat

Crontab sourcing PATH?

Hi, Im trying to run script A which requires path /sbin. I have a crontab entry to run script A every 10 minutes. Script A is executed fine by cron, but because script A requires /sbin in its path it fails to run. My situation is script A get overwritten from time to time so I can't modify... (4 Replies)
Discussion started by: wilsonee
4 Replies

4. Shell Programming and Scripting

Script working when run manually but not in crontab showing path not found

i have a script running using variable defined in .profile when i run that script manually its working but when i run the same script through cron its giving path not found I had defined path in .profile (3 Replies)
Discussion started by: raj_saini20
3 Replies

5. Solaris

cannot add PATH to user crontab file

hi All, here is the problem: I'm not able to specify a PATH inside the user crontab file (/var/spool/cron/crontabs). The only syntax it accepts is the usual "* * * * * file" I'm not able to add PATH, or HOME, or MAILTO, or anything else. when I try to save the crontab, I have the error: ... (1 Reply)
Discussion started by: joe_x
1 Replies

6. Red Hat

redhat 5.2 tikanga crond running but not reading crontab file

Issue:crond is running, can even restart it and /var/log/cron shows it starting. The /etc/crontab file is correct as compared to another machine. I set the crontab file to enter a datestamp into a file under /tmp every minute. Thing is, the crontab file is not being read or cron is not working... (12 Replies)
Discussion started by: robjmarquez
12 Replies

7. Shell Programming and Scripting

absolute path for a script ran with relative path

I have a script in which i want to print absolute path of the same script irrespective of path from where i run script. I am using test.sh: echo "pwd : `pwd`" echo "script name: $0" echo "dirname: `dirname $0`" when i run script from /my/test/dir/struct as ../test.sh the output i... (10 Replies)
Discussion started by: rss67
10 Replies

8. Shell Programming and Scripting

Maintain full path of a script in a var when sourcing it from a different script

Hi All, I've searched through the forum for a solution to this problem, but I haven't found anything. I have 2 script files that are in different directories. My first script, let's call it "/one/two/a.sh" looks like this: #!/bin/sh IN_DIR=`dirname $0` CUR_DIR=`pwd` cd $IN_DIR... (4 Replies)
Discussion started by: mrbluegreen
4 Replies

9. UNIX for Dummies Questions & Answers

crontab and path

hi All, here the problem: I'm not able to specify a PATH inside the crontab file. The only syntax it accepts is the usual "* * * * * file" I'm not able to add PATH, or HOME, or MAILTO, or anything else. when I try to save the crontab, I have the error: "crontab: error on previous line;... (3 Replies)
Discussion started by: fuliggians
3 Replies

10. Shell Programming and Scripting

Reading a path (including ref to shell variable) from file

Hi! 1. I have a parameter file containing path to log files. For this example both paths are the same, one is stated directly and the second using env variables. /oracle/admin/orcl/bdump/:atlas:trc:N ${ORACLE_BASE}/admin/${ORACLE_SID}/bdump/:${ORACLE_SID}:trc:N 2. I try to parse the path... (1 Reply)
Discussion started by: lojzev
1 Replies
Login or Register to Ask a Question