Shell script to generate daily crontab entries between to specific dates
Hi,
I am currently writing a shell script to enter daily reoccurring jobs into the crontab. I want to be able to specify any two dates for which I want these daily jobs to run between.
Below is an example of what I need to be written to crontab.
# Give a start day of 21/10/2009 09:00 and end day of 23/10/2009 09:00, we need the following crontab entries:
...
How would I go about running through all the days between 2 particular dates?
...
You can generally specify ranges and lists for the 3rd field i.e. day of the month. Check your man page for confirmation though.
So, for this case -
the following crontab entry is sufficient:
I have assumed that the input date parametes were passed only for the date-check criterion. If they are actually used in your script for some other purpose, then you'll have to pass them.
Quote:
...Currently, I am assuming that the two date span within a month, ...
Crontab entries for this case are simple. As an example, if you want to run a script at 9 AM on the 3rd, 5th, 15th, and 28th day and all days from 18th through 23rd of October, then you can mix lists (d1, d2, d3) and ranges (d1-d2, d3-d4) thusly:
A "*" for "day of week" (5th field) means that the day of week is disregarded.
Quote:
...but I want to extend this so that the dates can span across any time frame...
Things are not as simple for this case. In general, you can do this:
The <date_check_script> is a shell script that returns 0 if today lies within the intended date-range (the date-range might span a year or two, for example).
If the script is to be run at 9 AM every day from, say, 1-Nov-2009 through 30-Jun-2010, then you could have this:
and your <date_check_script> should return 0 if
(a) current month is [11,12] and year is 2009, or
(b) current month is [1-6] and year is 2010.
Hi,
I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service)
lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Hi,
I've written a shell script with proper intentation and commenting structure. However, I would like to generate documentation for the shell which I have written. Is there any tool as such to generate it like we have javagen/docgen ?
Please help.
Thanks,
Arjun (0 Replies)
I am trying to run a script from crontab but the entire script (which is 70+ lines) is written in bash and I need it to run from a certain directory.
So when I run it manually I cd to /local/mnt/scr and then type ./reordersc and it works fine.
However, I want it to run from the crontab and I... (20 Replies)
Hi All,
I am looking into a script which will give me a future dates for 7 days, including next month dates in case if runs on month ends...
I an able to get this in Linux but not working for Solaris.
OS: Solaris 10
Please help (6 Replies)
Unix Gurus,
I have a shell script which has few "echo" statements. I am trying to create a logfile where all the outputs of the echo statement sare stored.
I will have to add this as the final step in the existing script so that everytime the script runs, a logfile is generated with all the... (1 Reply)
Hi,
I have a script that handles a huge amount of log files from many machines and copies it into a SAN location with the following directory structure:
/SAN/machinenames/yyyy/m/d
so for example
/SAN/hosta/2011/3/12/files*
Now I am writing a bash script to search for files between to date... (4 Replies)
let says, today is my payroll day (7/26), my next payroll day will be 8/9. i want to generate a shell script to extract 8/9, 8/23, 9/6, and so on for 2010. (2 Replies)
Dear Friends,
I am working on IBM AIX. I have written one script and kept in the crontab as to run daily at 11:38 AM. and the output of the script to be appended to the file generated with the month name. but my file deleting daily and the new file is creating with the output of the shell... (2 Replies)
Hello friends,
I am looking for a script or method that can display all the dates between any 2 given dates.
Input:
Date 1
290109
Date 2
010209
Output:
300109
310109
Please help me. Thanks. :):confused: (2 Replies)
Hello!
I would like to generate an xml file from the output of various commands generated from within a shell script (some will be in CDATA).
At the moment the only solution I have come up with is echoing xml tags around the commands eg.
echo "<bitism>" >> outputfile
/usr/sbin/prtconf... (1 Reply)