- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script help - Dates
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
04-26-2002 12:29 PM
04-26-2002 12:29 PM
faxdbdel -OUTBOUND -to YYMMDD
The user wants to keep 2 weeks worth in the db. I figured I would write a cron script which is called daily to accomplish this, but I'm having some problems trying to load the command with the correct day (DD) of 2 weeks ago. Any ideas?
thanks,
Greg
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 12:34 PM
04-26-2002 12:34 PM
Re: Script help - Dates
To get the day of month is
date +%d day of month
date +%a for week day etc..
If you don't mind post your script or part of script which has problem.
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 12:36 PM
04-26-2002 12:36 PM
Re: Script help - Dates
I'm certainly not going to take credit for this, but Mr Stephenson's 'caljd.sh' script will do this job. I'm sure you find it easily by searching, or it may even be posted by Clay himself.
Cheers
~Michael~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 12:40 PM
04-26-2002 12:40 PM
SolutionDAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)
echo "DAY=${DAY}"
The inner caljd.sh returns the Julian Day 14 days ago and the outer caljd.sh says format in YYYY MM DD format (-e) and reove the spaces (-s) to yield YYYYMMDD. The cut then says returns characters 3 to the end of string or YYMMDD - just what you asked for.
See the attached caljd.sh. Caljd.sh -u will give full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 12:40 PM
04-26-2002 12:40 PM
Re: Script help - Dates
GL,
C
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 01:03 PM
04-26-2002 01:03 PM
Re: Script help - Dates
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 01:06 PM
04-26-2002 01:06 PM
Re: Script help - Dates
Thanks,again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 01:40 PM
04-26-2002 01:40 PM
Re: Script help - Dates
For instance:
04=Apr
thanks,
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 01:55 PM
04-26-2002 01:55 PM
Re: Script help - Dates
#!/usr/bin/sh
MO[01]="Jan"
MO[02]="Feb"
MO[03]="Mar"
MO[04]="Apr"
MO[05]="May"
MO[06]="Jun"
MO[07]="Jul"
MO[08]="Aug"
MO[09]="Sep"
MO[10]="Oct"
MO[11]="Nov"
MO[12]="Dec"
DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)
echo "DAY=${DAY}"
MONTH=${MO[$(caljd.sh -M $(caljd.sh -p 14))]}
echo "Month=${MONTH}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 02:24 PM
04-26-2002 02:24 PM
Re: Script help - Dates
Yet another way to convert 04 to "Apr" although I like the previous method better; it's less obscure.
#!/usr/bin/sh
SMONTH="???JanFebMarAprMayJunJulAugSepOctNovDec"
DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)
echo "DAY=${DAY}"
NMONTH=$(caljd.sh -M $(caljd.sh -p 14))
OFFSET=$(((${NMONTH} * 3) + 1))
STOP=$((${OFFSET} + 2))
MONTH=$(echo ${SMONTH} | cut -c ${OFFSET}-${STOP})
echo "MONTH=${MONTH}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 02:30 PM
04-26-2002 02:30 PM
Re: Script help - Dates
Thank again,
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2002 05:39 PM
04-26-2002 05:39 PM
Re: Script help - Dates
Without the dummy values for month 0 the offset calculations become offset = ((month - 1) * 3) + 1 - even more messy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2002 07:03 AM
04-27-2002 07:03 AM
Re: Script help - Dates
Your last question did make me realize that there was a better way still to do the offset into the month string. Use two '?'s and then it is not necessary to subtract 1 so that offset = (month * 3).
#!/usr/bin/sh
SMONTH="??JanFebMarAprMayJunJulAugSepOctNovDec"
DAY=$(echo $(caljd.sh -y -s $(caljd.sh -p 14)) | cut -c 3-)
echo "DAY=${DAY}"
NMONTH=$(caljd.sh -M $(caljd.sh -p 14))
OFFSET=$((${NMONTH} * 3))
STOP=$((${OFFSET} + 2))
MONTH=$(echo ${SMONTH} | cut -c ${OFFSET}-${STOP})
echo "MONTH=${MONTH}"