- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell script for days
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
тАО06-25-2009 07:15 AM
тАО06-25-2009 07:15 AM
I need to ping a server daily but only on business days i.e. Monday to Friday. How would I do that.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2009 07:27 AM
тАО06-25-2009 07:27 AM
Re: Shell script for days
00 05 * * 1-5 "/usr/sbin/ping servername -n 3"
Pete
Pete
- Tags:
- crontab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2009 07:29 AM
тАО06-25-2009 07:29 AM
Re: Shell script for days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2009 07:54 AM
тАО06-25-2009 07:54 AM
Re: Shell script for days
> I need it in a shell script
Pete gave you a shell script, albeit a commandline one. What's wrong with that?
If you insist, encapsulate his suggestion like this:
# cat ./myping
#!/usr/bin/sh
/usr/sbin/ping servername -n 3
...and make an entry in your 'crontab' like Pete suggested:
00 05 * * 1-5 /absolute_path_to/myping
...which runs a 0500 on Monday-Friday.
And since the output isn't redirected, you (the initiating user) will receive a mail message of the results.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2009 07:56 AM
тАО06-25-2009 07:56 AM
Re: Shell script for days
$ date +%u
4
Tells me it's Thursday. Skip 6 and 7 and you're all set.
Pete
Pete
- Tags:
- date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2009 08:13 AM
тАО06-25-2009 08:13 AM
SolutionTo add to Pete's suggestion, I would _not_ use:
# date +%u
...but rather:
# date +%w
...as in:
# WEEKDAY=$(date +%w)
# echo ${WEEKDAY}
The "%w" format returns values 0-6 for Sunday-Saturday, whereas "%u" returns 1-7 for Monday-Sunday.
The '0-6' coding is consistent with a crontask and is the more common expectation in coding.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-25-2009 08:49 AM
тАО06-25-2009 08:49 AM
Re: Shell script for days
Good all purpose date/day utility script.
http://mirrors.develooper.com/hpux/caljd-2.25.sh
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-26-2009 12:22 AM
тАО06-26-2009 12:22 AM
Re: Shell script for days
There is such a thing as a comment. :-)