Sponsored Content
Full Discussion: Run script on particular day
Top Forums Shell Programming and Scripting Run script on particular day Post 303025096 by rohit_shinez on Wednesday 24th of October 2018 10:04:21 AM
Old 10-24-2018
Here is what i am trying

Code:
current_day=$(date +%e)
current_time=$(date +"%H:%M")
current_month=$(date +"%m")

if [ $current_day == 25 ] && [ $current_time == '10:00' ]
      sh -x script_1.sh && break  
 fi

if [ $current_time == '10:00' ]
then
   sh -x script_2.sh
fi

if [ $current_month == 4 ] || [ $current_month == 8 ] || [ $current_month == 12 ]
then 
  if [ $current_day == 30 ] && [ $current_time == '10:00' ]
    then
      sh -x script_3.sh
  fi
fi

For instance if my script_1 fails on 25th and trying to re-run the main_script.sh on next day, then it should run only script_1.sh instead of script_2.sh because script_2.sh was already successful on 25th
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies

2. 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

3. Shell Programming and Scripting

crontab entry to run every last day of the month

i've created a script which should run every last day of the month. what would be the exact crontab entry for this? thanks! (9 Replies)
Discussion started by: tads98
9 Replies

4. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

5. AIX

kill process that run more then 1 day

hi all i need a script which will find all the processes witht the name of xxx and kill all those processes that runs for more than 1 day. Regards (3 Replies)
Discussion started by: Elii
3 Replies

6. Shell Programming and Scripting

Script to check if last modified day is previous day

Hi, I would like to write a script that checks if a file ('counter') was modified the previous day, if so erase its contents and write 00000000 into it. For e.g. if the file 'counter' was last modified at 11.30pm on 24th May and the script runs at 12.15am of 25th May, it should erase it's... (1 Reply)
Discussion started by: hegdepras
1 Replies

7. 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

8. 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

9. UNIX for Advanced & Expert Users

Run A Job in Cron On A Specific Day Excluding Holidays

Hi, I want to run a job in cron on a specific date(say 25th of every month) excluding holidays. Can anyone provide some hints to do this? Thanks for any inputs. (1 Reply)
Discussion started by: sktkpl
1 Replies

10. 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
MAILDROPEX(7)						      Double Precision, Inc.						     MAILDROPEX(7)

NAME
maildropex - maildrop filtering language examples SYNOPSIS
$HOME/.mailfilter, $HOME/.mailfilters/* DESCRIPTION
If $HOME/.mailfilter exists, filtering instructions in this file will be carried out prior to delivering the message. The filtering instructions may instruct maildrop to discard the message, save the message in a different mailbox, or forward the message to another address. If $HOME/.mailfilter does not exist, or does not provide explicit delivery instructions, maildrop delivers the message to the user's system mailbox. The files in $HOME/.mailfilters are used when maildrop is invoked in embedded mode. EXAMPLES
Take all mail that's sent to the 'auto' mailing list, and save it in Mail/auto. The 'auto' mailing list software adds a "Delivered-To: auto@domain.com" header to all messages: if (/^Delivered-To: *auto@domain.com$/) to Mail/auto After the to command delivers the message, maildrop automatically stops filtering and terminates without executing the subsequent instructions in the filter file. Take all mail from boss@domain.com about the current project status, save it in Mail/project, then forward a copy to John: if (/^From: *boss@domain.com/ && /^Subject:.*[:wbreak:]project status[:wbreak:]/) { cc "!john" to Mail/project } Note that it is necessary to use a backslash in order to continue the if statement on the next line. Keep copies of the last 50 messages that you received in the maildir directory 'backup'. NOTE: 'backup' must be a maildir directory, not a mailbox. You can create a maildir using the maildirmake command. cc backup `cd backup/new && rm -f dummy `ls -t | sed -e 1,50d`` Put this at the beginning of your filter file, before any other filtering instructions. This is a good idea to have when you are learning maildrop. If you make a mistake and accidentally delete a message, you can recover it from the backup/new subdirectory. Save messages that are at least 100 lines long (approximately) into Mail/IN.Large:: if ( $LINES > 100 ) to Mail/IN.Large Send messages from the auto mailing list to the program 'archive', using a lock file to make sure that only one instance of the archive program will be running at the same time: if (/^Delivered-To: *auto@domain.com$/) dotlock "auto.lock" { to "|archive" } Check if the Message-ID: header in the message is identical to the same header that was recently seen. Discard the message if it is, otherwise continue to filter the message: `reformail -D 8000 duplicate.cache` if ( $RETURNCODE == 0 ) exit The reformail[1] command maintains a list of recently seen Message-IDs in the file duplicate.cache. Here's a more complicated example. This fragment is intended to go right after the message has been filtered according to your regular rules, and just before the message should be saved in your mailbox: cc $DEFAULT xfilter "reformail -r -t" /^To:.*/ getaddr($MATCH) =~ /^.*/; MATCH=tolower($MATCH) flock "vacation.lock" { `fgrep -iqx "$MATCH" vacation.lst 2>/dev/null || { echo "$MATCH" >>vacation.lst ; exit 1 ; } ` } if ( $RETURNCODE == 0 ) exit to "| ( cat - ; echo ''; cat vacation.msg) | $SENDMAIL" This code maintains a list of everyone who sent you mail in the file called vacation.lst. When a message is received from anyone that is not already on the list, the address is added to the list, and the contents of the file vacation.msg are mailed back to the sender. This is intended to reply notify people that you will not be answering mail for a short period of time. The first statement saves the original message in your regular mailbox. Then, xfilter[2] is used to generate an autoreply header to the sender. The To: header in the autoreply - which was the sender of the original message - is extracted, and the getaddr[3] function is used to strip the person's name, leaving the address only. The file vacation.lst is checked, using a lock file to guarantee atomic access and update (overkill, probably). Note that the backslashes are required. If the address is already in the file, maildrop exits, otherwise the contents of vacation.msg are appended to the autoreply header, and mailed out. Note An easier to make a vacation script is with mailbot(1)[4]. Here's a version of the vacation script that uses a GDBM database file instead. The difference between this script and the previous script is that the previous script will send a vacation message to a given E-mail address only once. The following script will store the time that the vacation message was sent in the GDBM file. If it's been at least a week since the vacation message has been sent to the given address, another vacation message will be sent. Even though a GDBM database file is used, locking is still necessary because the GDBM library does not allow more than one process to open the same database file for writing: cc $DEFAULT xfilter "reformail -r -t" /^To:.*/ getaddr($MATCH) =~ /^.*/; MATCH=tolower($MATCH) flock "vacation.lock" { current_time=time; if (gdbmopen("vacation.dat", "C") == 0) { if ( (prev_time=gdbmfetch($MATCH)) ne "" && $prev_time >= $current_time - 60 * 60 * 24 * 7) { exit } gdbmstore($MATCH, $current_time) gdbmclose } } to "| ( cat - ; echo ''; cat vacation.msg) | $SENDMAIL" This script requires that maildrop must be compiled with GDBM support enabled, which is done by default if GDBM libraries are present. After you return from vacation, you can use a simple Perl script to obtain a list of everyone who sent you mail (of course, that can also be determined by examining your mailbox). SEE ALSO
maildrop(1)[5], maildropfilter(7)[6], reformail(1)[1], mailbot(1)[4], egrep(1), grep(1), sendmail(8). AUTHOR
Sam Varshavchik Author NOTES
1. reformail [set $man.base.url.for.relative.links]/reformail.html 2. xfilter [set $man.base.url.for.relative.links]/maildropfilter.html#xfilter 3. getaddr [set $man.base.url.for.relative.links]/maildropfilter.html#getaddr 4. mailbot(1) [set $man.base.url.for.relative.links]/mailbot.html 5. maildrop(1) [set $man.base.url.for.relative.links]/maildrop.html 6. maildropfilter(7) [set $man.base.url.for.relative.links]/maildropfilter.html Courier Mail Server 08/30/2011 MAILDROPEX(7)
All times are GMT -4. The time now is 04:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy