06-01-2010
Mumbai time is UTC/GMT plus 5:30.
01:00 in Mumbai is 19:30 Greenwich Mean Time (GMT) "yesterday".
Assuming that your cron runs in Mumbai Time the definition of "yesterday" and "day-before-yesterday" when expressed in Greenwich Mean Time (GMT) changes according to the time parameter of the crontab entry.
I don't think that changing the TZ variable in this manner is a valid technique outside of the GMT timezone. You need to be working in the same timezone as cron.
Depending on what Operating System and Shell you have there are published techniques for date arithmetic for non-GMT timezones.
Alternatively you could test the cron every hour for 24 hours and use this information to work out a simple adjustment.
Afterthought. You could create a cron for 00:01 to create a file for "today" and age the file daily to produce "yesterday" and "day-before-yesterday". With forward planning you will have all the reference dates available after three days. The content of each file can be the output from "date" in whatever format you require. This will be a lot less hassle than date arithmetic.
Last edited by methyl; 06-01-2010 at 08:27 PM..
Reason: afterthought
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a backup script that is suppose to run every night of the week, but it never does, it starts to run. The way I can tell is that the dates on dump_log are changing to when the script runs. If I look in the cron log file is shows
! > root 506342 cr /etc/back_up Fri Aug 5 10:30:00... (2 Replies)
Discussion started by: rickyt00
2 Replies
2. UNIX for Advanced & Expert Users
Hi ,
I have written a shell script that takes the current date on the server and stores it in a file.
echo get /usr/home/data-`date '+%Y%d'`.xml> /usr/local/sandeep/GetFILE.ini
I call this GetFILE.ini file from an sftp program to fetch a file from /usr/home/ as location. The file is in... (3 Replies)
Discussion started by: bsandeep_80
3 Replies
3. UNIX for Dummies Questions & Answers
Hi All,
There is a requirement to create a file everyday using the cronjob with the date as its name.
any suggestions for the crontab command that'll serve this purpose?
e.g.
02 30 * * * touch abcd.`date +%d.%m.%y`
needless to say.. this doesn't work..
looking fwd to lots of... (7 Replies)
Discussion started by: pranavagarwal
7 Replies
4. Shell Programming and Scripting
Helo .
I have 2.6.13-1.1526_FC4smp here.
I am trying to make crontab execute my simple shell script, but noting happens.
here is how i am testing this :
$ pwd
/home/oracle
$ ls -l two*
ls: two*: No such file or directory
$
$ crontab -e
crontab: installing new crontab
$
$ crontab... (7 Replies)
Discussion started by: tonijel
7 Replies
5. Shell Programming and Scripting
Hello Experts,
I am facing problem in date command with TZ
test.sh
Output : 26-May-2010 27-May-2010
I scheduled this script everyday at 1 a.m
00 01 * * * sh test.sh
when i was called this script test.sh from crontab , it was giving me other output (1 Reply)
Discussion started by: pritish.sas
1 Replies
6. Shell Programming and Scripting
I have a ksh script which will connect to a database and executes some sql scripts. If i run the ksh script it is working fine. But if i schedule it to run at a perticular time using cron the sql script is not running. The scriptl initially creates a spool file for sql script and then connects and... (12 Replies)
Discussion started by: Sriranga
12 Replies
7. UNIX for Advanced & Expert Users
We have configured a script to be run at specific time using crontab.
# crontab -l
15 11 * * * VM_Count_V4.shas per the crontab entry script should run every day 11.15 a.m
Every time when the script is executed i get a mail but when i run it using crontab it doesn't send any mail.
However... (1 Reply)
Discussion started by: pinga123
1 Replies
8. Solaris
SOLARIS 9 Zone :
date command in crontab shows delayed(One Hour) output
Hi folks,
the date command shows the correct date and time, How ever, if the date command executed through crontab in any form of scrip the output shows as one hour delayed, similar to date -u..
Can some one help in... (12 Replies)
Discussion started by: judi
12 Replies
9. Shell Programming and Scripting
hi,
i have schduled a job through crontab, but it is not getting executed.
bash-3.2$ crontab -l
# Monthly Download (mm hh DD MM format)
35 05 01 04 * /home/ftpsrp/srpftp1/download/ofrdb/scripts/load_ofrdb.sh crr.sh
here is the permission of the .sh files
-rwxr--r-- 1 ftpsrp srp ... (7 Replies)
Discussion started by: lovelysethii
7 Replies
10. UNIX for Advanced & Expert Users
My colleague who was a sysadmin , has created a cron job script which collects logs and process them.
The script works perfectly as per the defined time set by him.
it works when we keep the timing as 55 05 * * * , whereas if we try to prepone the cron task is not getting executed.
Where... (10 Replies)
Discussion started by: aravindj80
10 Replies
LEARN ABOUT DEBIAN
time::parsedate
Time::ParseDate(3pm) User Contributed Perl Documentation Time::ParseDate(3pm)
NAME
Time::ParseDate -- date parsing both relative and absolute
SYNOPSIS
use Time::ParseDate;
$seconds_since_jan1_1970 = parsedate("12/11/94 2pm", NO_RELATIVE => 1)
$seconds_since_jan1_1970 = parsedate("12/11/94 2pm", %options)
OPTIONS
Date parsing can also use options. The options are as follows:
FUZZY -> it's okay not to parse the entire date string
NOW -> the "current" time for relative times (defaults to time())
ZONE -> local timezone (defaults to $ENV{TZ})
WHOLE -> the whole input string must be parsed
GMT -> input time is assumed to be GMT, not localtime
UK -> prefer UK style dates (dd/mm over mm/dd)
DATE_REQUIRED -> do not default the date
TIME_REQUIRED -> do not default the time
NO_RELATIVE -> input time is not relative to NOW
TIMEFIRST -> try parsing time before date [not default]
PREFER_PAST -> when year or day of week is ambiguous, assume past
PREFER_FUTURE -> when year or day of week is ambiguous, assume future
SUBSECOND -> parse fraction seconds
VALIDATE -> only accept normal values for HHMMSS, YYMMDD. Otherwise
days like -1 might give the last day of the previous month.
DATE FORMATS RECOGNIZED
Absolute date formats
Dow, dd Mon yy
Dow, dd Mon yyyy
Dow, dd Mon
dd Mon yy
dd Mon yyyy
Month day{st,nd,rd,th}, year
Month day{st,nd,rd,th}
Mon dd yyyy
yyyy/mm/dd
yyyy-mm-dd (usually the best date specification syntax)
yyyy/mm
mm/dd/yy
mm/dd/yyyy
mm/yy
yy/mm (only if year > 12, or > 31 if UK)
yy/mm/dd (only if year > 12 and day < 32, or year > 31 if UK)
dd/mm/yy (only if UK, or an invalid mm/dd/yy or yy/mm/dd)
dd/mm/yyyy (only if UK, or an invalid mm/dd/yyyy)
dd/mm (only if UK, or an invalid mm/dd)
Relative date formats:
count "days"
count "weeks"
count "months"
count "years"
Dow "after next"
Dow "before last"
Dow (requires PREFER_PAST or PREFER_FUTURE)
"next" Dow
"tomorrow"
"today"
"yesterday"
"last" dow
"last week"
"now"
"now" "+" count units
"now" "-" count units
"+" count units
"-" count units
count units "ago"
Absolute time formats:
hh:mm:ss[.ddd]
hh:mm
hh:mm[AP]M
hh[AP]M
hhmmss[[AP]M]
"noon"
"midnight"
Relative time formats:
count "minutes" (count can be franctional "1.5" or "1 1/2")
count "seconds"
count "hours"
"+" count units
"+" count
"-" count units
"-" count
count units "ago"
Timezone formats:
[+-]dddd
GMT[+-]d+
[+-]dddd (TZN)
TZN
Special formats:
[ d]d/Mon/yyyy:hh:mm:ss [[+-]dddd]
yy/mm/dd.hh:mm
DESCRIPTION
This module recognizes the above date/time formats. Usually a date and a time are specified. There are numerous options for controlling
what is recognized and what is not.
The return code is always the time in seconds since January 1st, 1970 or undef if it was unable to parse the time.
If a timezone is specified it must be after the time. Year specifications can be tacked onto the end of absolute times.
If "parsedate()" is called from array context, then it will return two elements. On sucessful parses, it will return the seconds and what
remains of its input string. On unsucessful parses, it will return "undef" and an error string.
EXAMPLES
$seconds = parsedate("Mon Jan 2 04:24:27 1995");
$seconds = parsedate("Tue Apr 4 00:22:12 PDT 1995");
$seconds = parsedate("04.04.95 00:22", ZONE => PDT);
$seconds = parsedate("Jan 1 1999 11:23:34.578", SUBSECOND => 1);
$seconds = parsedate("122212 950404", ZONE => PDT, TIMEFIRST => 1);
$seconds = parsedate("+3 secs", NOW => 796978800);
$seconds = parsedate("2 months", NOW => 796720932);
$seconds = parsedate("last Tuesday");
$seconds = parsedate("Sunday before last");
($seconds, $remaining) = parsedate("today is the day");
($seconds, $error) = parsedate("today is", WHOLE=>1);
LICENSE
Copyright (C) 1996-2010 David Muir Sharnoff. Copyright (C) 2011 Google, Inc. License hereby granted for anyone to use, modify or
redistribute this module at their own risk. Please feed useful changes back to cpan@dave.sharnoff.org.
perl v5.12.3 2011-05-20 Time::ParseDate(3pm)