- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- File Name based on yesterday's date
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
Forums
Discussions
Discussions
Discussions
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
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
11-11-2002 12:42 PM
11-11-2002 12:42 PM
I am trying to use A. Clay Stephenson's caljd.sh script to generate a filename based upon yesterday's date unless today is Monday. I want Monday to use the previous Friday. These files and directories will be used to store backup information.
For example, for Nov. 11, 2002 (a Monday) I want the name to
be 2001/Nov/09 (previous Friday) but for Nov. 12, 2002 (a Tuesday) I want the name to be 2002/Nov/11 (Monday).
Does anybody know how to get caljd.sh to do this? A.Clay, are you out there?
TIA, Bob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2002 12:51 PM
11-11-2002 12:51 PM
SolutionFNAME=$(caljd.sh -y -S "/" -o $(caljd.sh -p 1 -x 0 -x 6))
the -p 1 says previous day; -x 0 skip Sun.; -x 6 skip Sat.
If I didn't make any typo's that should fix you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2002 12:52 PM
11-11-2002 12:52 PM
Re: File Name based on yesterday's date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2002 01:18 PM
11-11-2002 01:18 PM
Re: File Name based on yesterday's date
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2002 07:15 AM
11-12-2002 07:15 AM
Re: File Name based on yesterday's date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2002 07:25 AM
11-12-2002 07:25 AM
Re: File Name based on yesterday's date
If you use that little button called 'Search' and search for "caljd.sh", you can find it. To make it easy, I'll attach the latest version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2002 07:28 AM
11-12-2002 07:28 AM
Re: File Name based on yesterday's date
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2002 07:52 AM
11-12-2002 07:52 AM
Re: File Name based on yesterday's date
Thanks Again,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2002 11:42 AM
11-12-2002 11:42 AM
Re: File Name based on yesterday's date
o Add a cron job to touch a file every day at 23:59. For example:
59 23 * * 1-5 date +%Y/%b/%d > /tmp/yesterday
So on Tuesday, this file will contain Monday's date, on Wed. it'll contain Tuesday's date, and on Sat., Sun, and Monday, it'll have Friday's date.
o In your script, cat the /tmp/yesterday file to build your filename.
o Not perfect, but it works.
Maybe this'll help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2002 12:53 PM
11-12-2002 12:53 PM
Re: File Name based on yesterday's date
Clay,
Since you mentioned holidays, I don't want my cron backup scripts to run if it is a holiday. (Nobody will be here to change tapes.) In my cron script, is there an easy way to know if the current date is a holiday? My /etc/acct/holidays file is now current. I know I have to use -h, I just can't seem to get it quite right.
TIA, Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-12-2002 12:58 PM
11-12-2002 12:58 PM
Re: File Name based on yesterday's date
You guys are going to make me write a tutorial on caljd.sh. You are going to kick yourself because it is so simple.
if [[ $(caljd.sh) -ne $(caljd.sh -h) ]]
then
echo "Today is a holiday."
exit 0
else
echo "Today ain't no holiday. Do your thing."
fi
All that happens is that if today is a holiday then the -h actually returns the next Julian Day but returns the same Julian Day otherwise.