Simpler crontab entry to execute pgm on last day of the month
The following bash command line works for the last day of the month. Test by replacing the 1 with tomorrows day of month number
Can it be used within crontab? As
I tried to test crontab with the above entry (forcing dates) and I was was not able to get results
Last edited by lsatenstein; 03-17-2015 at 07:48 AM..
Reason: Discovered that %d in crontab needs % to be escaped
When the command works from the command line, what is the output from the command?:
Do you really want to run this command every minute of every hour 1 to 4 days every month?
The correct syntax for a numeric comparison in [ expression ] is:
not:
assuming that the date utility found on the system's default $PATH setting accepts a -d option on your system.
date +%d prints 01 on the 1st; which is not the same as 1 when performing a string comparison. You could also try a string comparison (which should use =; not ==), if you use date +%e instead of %d:
and this is probably safer than a numeric comparison. (Note that:
will give you a syntax error in some shells on the 8th and 9th days of the month because 08 and 09 are not valid octal values.)
I have query apply crontab entry that the script executes as below
day hours (before 8:00 PM and after 7:00 AM) execute every 5 min
in Night hours (after 8:00 PM to 7:00 AM) executes every 15 min
How can we set such entry in crontab ? (4 Replies)
I have created this program to get the next month and year. Is there a simpler way.
#!/bin/ksh
string=`cat Date.txt`
year=`echo $string | cut -c 1-4`
month=`echo $string | cut -c 5-6`
echo $year$month
mon=`expr $month + 1`
if ; then
mon=0$mon
echo $mon
fi
if ; then
month=01
... (2 Replies)
Hello Guys,
I have a questions regarding running a shell script every second working day each month.
I have no clue how solve this problem :wall:.
Important is that it has to be the second working (Mo-Fr).
Example: If 1st and 2nd Days of month are Sat and Sun the script must run on 4th day... (5 Replies)
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)
Hello Friends,
I have a cron tab like this:
10,40 1-23 * * * /script
i want to skip only one execution at 00:10, so basically i want it to execute every hour at 10th and 40th minute, except 00:10.
Could anyone help me doing this
Thanks folks
:b: (4 Replies)
I am using the code below modified from a post I saw here regarding having the script write out future dates. The problem is that instead of making 8/1 it makes 7/32! Please help!
yy=`date +%Y`
mm=`date +%m`
dd=`date +%d`
echo "Today is : $yy $mm $dd"
#!/usr/bin/ksh
date '+%m... (5 Replies)
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)
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)