|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Schedule and Run By weekly shell script in cronjob
Hi All,
How to schedule a shell script(script name- byweeklyreport.sh) it should run by weekly in corn job or is there any script have to write to check week and then run the above script. example-1st run March 06 2013 2nd run March 20 2013 3rd run April 3 2013 like that please give some example except PERL Script Thanks all in advance Regards, Krupa |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Hi,
Sorry actually i need example for this,that you have provided information is not enough. Thanks Krupa |
|
#4
|
||||
|
||||
|
Every week Code:
0 0 * * 0 byweeklyreport.sh CronBuddy - a crontab sandbox Last edited by Jotne; 03-07-2013 at 07:56 AM.. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Depending on the OS you are using, you may have a cron setup that works for every two weeks, but by using the date command in your script you could schedule it weekly and they choose whether to actually execute or not. On many flavours of unix, you may find that Code:
date +%j gives the Julian date. Given that there are seven days in a week, you could schedule every Monday and then have a test for "Is today an even Julian date?" test at the top. Some other flavours will give the week of the year, and it's a similar thing, but probably using Julian date is the best. So an entry for cron:- Code:
$ crontab -e 0 4 * * 1 /home/myuser/myscript will run this every Monday at 4am. You could then code your script like this:- Code:
#!/bin/ksh juldate=`date +%j` ((jultest=$juldate/2)) ((jultest=$juldate*2)) if [ $juldate -ne $jultest ] then print "This is an odd week of the year." print "No actions performed." exit fi # I have confirmed it is an even numbered Monday, so proceed blah blah blah....... Of course, you could make the test -eq to say you want to ignore even numbered Mondays. The divide by two, multiply by two relys on odd numbers division getting the 0.5 truncated, so if the Julian date is 123, the half is only counted as 61, so double it again and you get 122. Test then finds that they are different. Does this help? Robin Liverpool/Blackburn UK |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Had you taken the time to read that man page, you would have found an example exactly dealing with and solving your problem.
|
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Hi, Actually my Requirement is like this :- I have shell script in kern shell ,have to run alternate week per month example-today's date is 27 Mar 2013 and my script will run today then for the next time when it will run it should check 1st what was the last run date(27 Mar 2013) if it is matched 15days from current date then run else sent a mail with waning mgs. i have a AWK command it is checking only within a month Code: Code:
date +%Y:%m:%d|awk -vFS=":" -vOFS=":" '{$3=$3-3;print}'suppose i am checking 20days from current date it is give some negative value(-8) ex-2013:03:-8 I hope you will understand my problem. Advance thanks for giving me solution. Thank you All. Regards, Krupa ---------- Post updated at 04:08 AM ---------- Previous update was at 04:05 AM ---------- Quote:
i don't think you are reading properly my thread please read carefully and replu me back Last edited by Franklin52; 03-26-2013 at 05:39 AM.. Reason: Code tags |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Best way to schedule script to run Ubuntu 10.04 | glev2005 | UNIX for Dummies Questions & Answers | 1 | 02-04-2011 12:42 PM |
| Schedule a script to run at 10am from mon to fri | firestar | Shell Programming and Scripting | 7 | 01-21-2011 12:24 PM |
| My script didn't run every run every minute at cronjob | ngaisteve1 | AIX | 4 | 08-13-2010 01:03 AM |
| How to schedule a cronjob to run every 15 mins ? | suresh_kb211 | Shell Programming and Scripting | 5 | 08-26-2009 04:57 AM |
| General Q: how to run/schedule a php script from cron jobs maybe via bash from shell? | lowmaster | Shell Programming and Scripting | 3 | 05-18-2009 09:32 AM |
|
|