- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: "date" command in a script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2001 07:20 PM
тАО01-16-2001 07:20 PM
I used the following two lines to generate a filename for daily export dump file.
seqid=`date -u +%m%d`
filename=exp_$seqid.dmp
However, the number i got from "date" was
always one day earlier than the system exact day. The output of "ls -l" is like
-rw-r--r-- 1 oracle oinstall 7933952 Jan 8 05:50 exp_0107.dmp
-rw-r--r-- 1 oracle oinstall 7968768 Jan 9 05:50 exp_0108.dmp
-rw-r--r-- 1 oracle oinstall 8438784 Jan 10 05:50 exp_0109.dmp
And the wired thing is, if i run
date -u +%m%d
at the shell prompt now, i got the expected number "0117" as for today(Wed Jan 17 11:25:27 EAT 2001).
What's wrong here?
Please help.
Jessica
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2001 07:32 PM
тАО01-16-2001 07:32 PM
Re: "date" command in a script
ls command lists the date/time when the dump file was last updated. Which is 0500 hours of the next day. If this is true then the script is behaving as expected. If you wish to update the dte when the dump files actually complete, just rename the file using the same script after the dump is created.
Hope it helps...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-16-2001 11:02 PM
тАО01-16-2001 11:02 PM
Re: "date" command in a script
As Vinit told you, there is a great chance that your 'date' command runs before midnight and that the dump finishes at 05 AM the next day.
You could start your dump using a temp file, and once finished move (rename) your temp file to the real name using your 'date' construct, like in:
mv tmp_file exp_`date -u +%m%d`.dmp
This would ensure that the file name is showing the date you want, i.e. the end_of_dump date.
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2001 12:43 AM
тАО01-17-2001 12:43 AM
Re: "date" command in a script
thanks for your suggestion. I will try it.
(use a temp name, then rename it.)
However, I didn't run "date -u +%m%d" before midnight. "date" and Oracle's "exp" command
were included in the same script which then triggered by a crontab that set as:
50 5 * * 1-5 /mypath/my_dump.sh 2>> /mypath/dump_err.log
In my_dump.sh, it has
# Oracle environment variables. (skipped)
# ....
seqid=`date -u +%m%d`
/oraclehome/bin/exp USERID=system/manager FULL=Y INCTYPE=incremental DIRECT=Y FILE=/BACKUP/exp_$seqid.dmp LOG=/mypath/exp_i.log
#####
Jessica
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2001 02:55 AM
тАО01-17-2001 02:55 AM
SolutionThe problem is due to you using the '-u' flag on the date command. This causes date to respond with the date in Coordinated Universal Time which equates to Greenwich Mean Time.
When your job runs at 05:50 EAT, this is either 22:50 or 23:50 the previous day GMT. When you ran the command at 11:25 EAT, GMT was the same day.
Simply remove the -u flag from the date command and you will get the correct day.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-17-2001 07:18 AM
тАО01-17-2001 07:18 AM