LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > AIX
User Name
Password
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.

Notices


Reply
  Search this Thread
Old 03-25-2010, 01:58 PM   #1
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
Emulating a week-day cron job with the at command?


Ok, here's the situation - at work I have a script which I have to run every morning to run some checks. If I forget and something has gone wrong then it will take me ages to fix! So, I created a script which does the checks and emails me if there is an issue. I was going to cron this to just run on weekdays however our unix admins won't allow us to use cron because they say it's too much hassle when doing backups etc because no matter what rules you put in, users end up writing their own "critical" processes which then need to be dealt with etc. This is fair enough. Mine isn't critical btw, it just makes my life a bit easier!

They do however let the "at" command be run. So - my idea was to create a script which at the bottom works out the next week day and re-submits itself after running using the "at" command.

My only issue is with the dates. How do I increment the current date by one? Obviously just adding one to the day isn't good enough because at month end this buggers up and also different months have different days. I'm loathed to write a long piece of code to calculate what month it is, whether adding one has crossed a month boundary etc... Surely there must be a more simple way!?? We have perl installed if that's any help.
One thing I did consider is that we use Oracle, so I could just sqlplus the output of TO_CHAR(SYSDATE)+1.

Has anyone any better ideas??

Thanks

Last edited by devnull10; 03-25-2010 at 01:59 PM.
 
Old 03-25-2010, 04:16 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
echo "/path/to/my/script"|at "9am tomorrow"

And in your script just check whether it's a working day or not.

if [ $(date "+%u") -le 5 ]; then do something;fi




Cheers,
Tink

Last edited by Tinkster; 03-25-2010 at 04:18 PM.
 
Old 03-25-2010, 04:41 PM   #3
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Original Poster
Rep: Reputation: 120Reputation: 120
I have a feeling that the version we are using doesn't support the "tomorrow" syntax - we are on AIX 5.1 and I think you just have something like [YYYY][MM]DDHHMM or something similar. So I think I have to specify a date. Also, what happens if the box is taken down for maintenance over the weekend and I have a scheduled job? Will it be remembered when the server is brought back up again?
 
Old 03-25-2010, 05:08 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by devnull10 View Post
I have a feeling that the version we are using doesn't support the "tomorrow" syntax - we are on AIX 5.1 and I think you just have something like [YYYY][MM]DDHHMM or something similar.
My commiserations ... maybe search google for "unix shell date calculation or arithmetic"; as I am on Linux I don't have the
"problem" and date does pretty much all I need.

That, or use perl.
http://search.cpan.org/~stbey/Date-C.../Date/Calc.pod

Quote:
Originally Posted by devnull10 View Post
So I think I have to specify a date. Also, what happens if the box is taken down for maintenance over the weekend and I have a scheduled job? Will it be remembered when the server is brought back up again?
My understanding is that the at-daemon (similar to anacron) will run
the missed out scripts on reboot. Of course that may not make you
popular with the admin folk, either.


Cheers,
Tink
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cron job: day of month / day of week conflict? geekpie Linux - General 2 10-21-2009 03:56 AM
How to set up a Cron Job to run every other week or every three months etc. kckabobus Linux - Newbie 3 04-03-2008 01:36 PM
Command not working in cron job, but works fine in root Roosta21 Linux - Software 4 11-22-2007 08:08 AM
cron job and boot command Thulemanden DamnSmallLinux 3 11-08-2006 12:22 AM
Cron Job help...how to write this command? pxumsgdxpcvjm Linux - Newbie 2 09-05-2006 04:42 AM

LinuxQuestions.org > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 10:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration