The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cron job starts new cron proccess ron76 SUN Solaris 3 05-11-2008 10:07 PM
Cron and Pseudo-Cron dingusmcghee UNIX for Dummies Questions & Answers 1 01-31-2008 08:58 AM
CRON usage for CRON job skyineyes UNIX for Dummies Questions & Answers 1 01-17-2008 06:17 AM
AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log Keith Johnson AIX 0 01-09-2008 04:32 PM
Cron : you are not authorized to use cron. Sorry. tt155 UNIX for Advanced & Expert Users 1 07-06-2005 07:37 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-08-2003
Registered User
 

Join Date: Jul 2003
Location: Canada
Posts: 10
Stumble this Post!
Question Can cron do this?

Can cron run a script on the 4th Saturday of the month, every month? I don't believe it can.

Here's what I have so far:

30 5 24-31 * 6 <command>
Forum Sponsor
  #2 (permalink)  
Old 10-08-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,444
Stumble this Post!
The syntax you show really should work, but it doesn't. It will run your script on each day of 24 through 31 and on each Saturday. This interpretation of the cron fields arose in System V and everyone who had right conformed.

Your math is off though. The 4th Saturday must occur on the 22 through the 28.

Try this:
30 5 * * 6 [ `date +%e` -gt 21 -a `date +%e` -lt 29 ] && <command>
  #3 (permalink)  
Old 10-09-2003
Registered User
 

Join Date: Jul 2003
Location: Canada
Posts: 10
Stumble this Post!
I did as you suggested but get this error:

sh: test: 0403-021 A ] character is missing.

Here is my syntax (modified for testing today):

57 13 * * 4 [ `date +%e` -gt 8 -a `date +%e` -lt 11 ] && mail -s "cron test" me@homer.com < /users/me/test.txt

Any ideas?
  #4 (permalink)  
Old 10-09-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,444
Stumble this Post!
I have actually put code in a crontab and I too am getting the same error. That is odd since we have some very similiar tests in working crontabs. I don't have time to dig into now, but I will soon. In the meantime you could write a script called week4 that returns 0 or 1 depend on the week. And then use
week4 && command

This has actually exposed a very interesting problem. Right now I'm thinking that cron jobs are pumped through a proto file just like at jobs.
  #5 (permalink)  
Old 10-10-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,444
Stumble this Post!
There seem to be two issues: first everything after a per cent sign is getting truncated. You would think that I would have encountered a cron command before that used a %, but I guess that this must be my first. Also the backtick expressions are not being evaluated.

The syntax that works for me is:
* * * * * eval [ `date +\%e` -gt 8 -a `date +\%` -lt 11] && <command>

This is ugly enough that some cool script is needed. I'll write one this weekend.
  #6 (permalink)  
Old 10-10-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,444
Stumble this Post!
Excuse my continuing monologue

Anything after a % is stripped off a cron command and is feed as standard input into the command. This is mentioned on crontab(1) manpage. SunOS even has an example on their manpage.
  #7 (permalink)  
Old 10-10-2003
Registered User
 

Join Date: Jul 2003
Location: Canada
Posts: 10
Stumble this Post!
Smile

Thanks. I will test and advise.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0