- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How many days until a certain 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
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
тАО03-26-2003 08:23 AM
тАО03-26-2003 08:23 AM
This should be simple but I can't seem to find a command that will work. I need to send out notices like "The system will be down for upgrades in 25 days." I can make a cron entry to call my script but my problem is that I can't find an easy way to calculate the number of days between the current date and some future date like July 4, 2003. This should be so easy but I'm stuck.
Thanks for any help,
Bob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2003 08:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2003 08:30 AM
тАО03-26-2003 08:30 AM
Re: How many days until a certain date?
#!/usr/bin/sh
DATE="7 4 2003"
DAYS=$(($(caljd.sh ${DATE}) - $(caljd.sh)))
if [[ ${DAYS} -ge 0 ]]
then
echo "Days until ${DATE} = ${DAYS}."
fi
That should do it. Caljd.sh -u will give full usage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2003 08:37 AM
тАО03-26-2003 08:37 AM
Re: How many days until a certain date?
Thanks,
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2003 09:35 AM
тАО03-26-2003 09:35 AM
Re: How many days until a certain date?
Guess who wrote this script?
I suppose that out dear Albert installed some sort of sniffer that checks the subjects of new problems for words related with dates, time etc.
When the bell is ringing he drops everything and rush to the nearest keyboard. ;)
No points please.
No offense A.
Good luck
Adam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-26-2003 09:56 AM
тАО03-26-2003 09:56 AM
Re: How many days until a certain date?
#! /bin/sh
#future date = July 4, 2003 (04-07-2003)
#current date
day=`date +%d`
month=`date +%m`
year=`date +%y`
doj=`date +%j`
new_day=4
new_month=7
i=1
daycount=0
while [ $i -lt $new_month ]
do
monthlength=`cal $i $year|awk '/[0-9]/{last=$NF}END {print last}'`
daycount=`expr $daycount + $monthlength`
i=`expr $i + 1`
done
((daycount+=new_day))
daycount=`expr $daycount - $doj`
echo $daycount" days between the current date and July 4, 2003"
Regards,
Sergejs