So, do you mean A) Consistently alternate weeks, or B) certain weeks of the month which could be:-
First & third Monday each month
Second & Fourth Monday each month
First, third and any possible fifth Monday each month
With all of these, you have to consider that there will either be an occasional extra week between runs (case 1 & 2) or occasions where the run is on consecutive weeks (case 3)
If you are after A then I have suggested a solution which you have not replied to. Could you consider that and let me know if I have it right, or if not, why not and I will try to modify my suggestion.
If you are after B then let me know which and I'm sure we can work it out.
Schedule and Run By weekly shell script in cronjob
Hi Rabin,
Sorry for delay reply.
below is the output for your program that you have given.--
This is an odd week of the year.
No actions performed.
But this is my simple Requirement.
i have to run a shell script a day in alternate week.
suppose today's date is Wednesday 27-Mar-2013 today will run
and next run date will be on 10-April-2013(Wednesday) after 14days gap.
Here my problem is when i will run on 10-April-2013 ,i have to check last run date (here last run date is 27-Mar-2013) and 14 days gap if it is matched 14 days from current date then run the shell script else give any msg.
about your Point..
i am not checking any even or odd day because i don't need that
2nd it may any day like Monday to Friday (but it should be alternate week from day of run)
3rd First, third and any possible fifth Monday each month ... Not like this.
Please understand my requirement and give me some solution.
If it is every two weeks, regardless of which month it falls into what I discussed in post #3 of this thread. Set the test operator highlighted in read to be -eq if you want to run on the odd weeks to be used and schedule the script for the correct day with cron. If you want it at 3am for instance, you can choose from a cron entry like one of these:-
The others are obvious.
I suppose that you could do it another way and have a reference file.
When you run the script, you could touch the file and therefore set the file time stamp, then with find you could test if it is old enough to run. Something like:-
Then schedule it to run on the required day each week. You will need to create the file for the first run. You can set a very old date as a timestamp to be sure:
I've left the find looking for files older that 12 days (-mtime +12) because if you run the script at the same time, the difference between the time of the touch command running might make it a bit pot-luck.
Do either of these help, or have I still missed the point?
i have a small doubt about date- How to get before 15 day’s date(28:Mar:2013 format) from current date. I tried with below code:- date +%d:%b:%Y|awk -vFS=":" -vOFS=":" '{$1=$1-30;print}'
it is giving correct result if both dates are coming within a month problem:- if before 15 day ‘s date is coming previous month the result is giving –Ve value.
Please send me this important solution.
Best Regards, Krupa
Last edited by krupasindhu18; 03-28-2013 at 05:15 AM..
Hello,
I have two crontabs, one for the root and one for another user. There is a script in my configurations that has to send a email. The script works and sends the emails when I run it by hand with either the root or the user, and when I program it in the root's crontab.
But! It does not... (3 Replies)
On Ubuntu 10.04 LTS, I would like to know the best way to schedule myscript.sh to run at a specified time, please provide examples and specify things like does cron have to be running, how do I check if cron is running and all that. I have tried unsuccessfully in the past to run the AT command,... (1 Reply)
Hi,
I need to write a shell script which will run i background and will execute other script only on Mon to Fri 10 AM but not on Sat and Sun.
I am able to set it to run on every day at 10AM but how to make it to run only on Mon to Fri
Thanks,
Firestar. (7 Replies)
In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all.
* * * * * script.sh
When I run it manually, I can run it. Is that anything wrong with the above line?
If I change it to something like below,... (4 Replies)
Hi,
I want to schedule a job to run every 15 mins through cron.
searched the forums and came up with this piece of code.i have given this in my crontab
0-59/15 * * * * sh /usr/ss/job
But its not being run. Have i made any mistake here.
Can any1 post the cron code for scheduling the... (5 Replies)
Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day.
Thats because:
The script itself pulls data (textfiles) from a... (3 Replies)
Hi
Im very new at working with unix and this problem I simply can not understand. I know there are a lot of threads about problems with shell scripts behaving differently when run from a terminal and from a cronjob. I have tried everything(almost) but I still havent cracked this problem.
Im... (15 Replies)
Hi all
Recently i had finished a perl script. When i run manually, the script work fine.
But when i wanted to put the script in cron, it didn't get the same output as it run manually. I felt that it only execute the script until certain line then it stop as i see most of the related files didn't... (6 Replies)
Hi ,
I have a shell script to perform some actions on sun solaris box . This script normally requires to be run as a different user. so, whenever i have to run this script, i need to sudo in as that user , enter the password and execute it. Now,I have to setup a cronjob to execute the script... (11 Replies)