run the script on every 31st of month.....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting run the script on every 31st of month.....
# 1  
Old 10-24-2011
run the script on every 31st of month.....

Hello expert,

I need a logic code {don't want to schedule into crontab} which can run some of my code on 31st of Jan, March, Mya, Aug, Oct, Dec.....


Ex:

if [date "+%b %d, %Y" -eq Oct 24, 2011] then
echo "success"
fi



Please help me in achieving this

Thanks
# 2  
Old 10-24-2011
Code:
day=`date +%d`
month="Jan, March, May, Aug, Oct, Dec"
echo $month | grep `date +%b`
[ $? -eq 0 -a "$day" -eq 31 ] && sh mycode.sh || echo "Not matching"


Last edited by jayan_jay; 10-24-2011 at 04:42 AM..
# 3  
Old 10-24-2011
You can specify the format the date command outputs man date from this you can see that date +%d qill return the day of the month.

So you could use something like the following
Code:
if [ $(date +%d) -eq 31] ; then
   #call your script
fi

# 4  
Old 10-24-2011
put in cronjob

Code:
0 10 31 * * * your_script

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run script on every last sunday of the month

Hi ALL, I have been testing this script to run for every last Sunday of the month,looks like month which have 5 sunday (july 2016 )is not passing this and failing every time. Here is what I am using, current_date=31 echo " CURRENT DAY -> $current_date" if ... (2 Replies)
Discussion started by: netdbaind
2 Replies

2. Shell Programming and Scripting

Script to run on 2 4 and 7 day of the month

I am looking for a unix script which could run a job on 2, 4 and 7 working day of the month. if the days are falling on the saturday/sunday. it should run on the next day. Thank you.. (9 Replies)
Discussion started by: tradingspecial
9 Replies

3. Shell Programming and Scripting

Run shell script alternate week per month

Hi All, Requirement :- 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... (2 Replies)
Discussion started by: krupasindhu18
2 Replies

4. Shell Programming and Scripting

Writing a script to run weekly/monthly - check for weekday or day-of-the-month

Hi all, I currently have a UNIX file maintenance script that runs daily as a cron job. Now I want to change the script and create functions/sub inside it that runs on a weekly or monthly basis. To run all the scripts' daily maintenance, I want to schedule it in cron as simply maint.sh... (1 Reply)
Discussion started by: newbie_01
1 Replies

5. Shell Programming and Scripting

run the script for last day of the month

Hello Experts, I have a script which i want to run the on last day of every month. let say I have backup.sh script which i want to run it every month last day. Can anyone please help :confused: thanks (4 Replies)
Discussion started by: aks_1902
4 Replies

6. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

7. Solaris

crontab entry to run a script on 1st of every month.

What should be the crontab entry in solaris to run a script on 1st of every month? Is this correct? 00 02 1 * * <script to be executed> (5 Replies)
Discussion started by: deepaksahni0109
5 Replies

8. UNIX for Dummies Questions & Answers

cron script -run every 2nd day of month except Monday

I know I can't schedule this in cron and would have to write a wrapper around my script and schedule it in cron ....but not sure how do to this? How do I exclude Monday if the 2nd day of the month falls on a Monday? Thanks. I tried this: 0 0 2 * 0,2-6 command And I know this doesnt... (2 Replies)
Discussion started by: newtou
2 Replies

9. UNIX for Advanced & Expert Users

How to scedule a script to be run on every second saturday in Month?

Hello Friends, In my project I have to schedule a script to be run on every second saturday (once in month). Can you please suggest what entry should I make in cron ? (5 Replies)
Discussion started by: sourabhsharma
5 Replies

10. UNIX for Advanced & Expert Users

Run a script parallel for a month's worth:

Is there a utility that can be used in a shell script that would run a .sql file for 30 or 31 days in a month at the same time parallely. Please Advice. Thanks SD12. (2 Replies)
Discussion started by: sd12
2 Replies
Login or Register to Ask a Question