- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- help with Cron job
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
02-08-2002 08:36 AM
02-08-2002 08:36 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 08:41 AM
02-08-2002 08:41 AM
Re: help with Cron job
first command: crontab -e to edit the crontable
0,5,10,15,20,25,30,35,40,45,50,55 * * * * ping ip_of_host >> /directory/logfile_you_want
everything in one line, you can also do this with SAM( routine tasks ).
Allways stay on the bright side of life!
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 08:42 AM
02-08-2002 08:42 AM
Re: help with Cron job
date >>/var/adm/logs/ping.log
ping [hostname] -n [count] >>/var/adm/logs/ping.log
where hostname is the host to ping, and count is the number of packets to send.
crontab entry,...
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /tmp/script
where /tmp/script is the script with the ping command.
Or else you can just enter the ping command straight on the cron line, instead of /tmp/script.
Hope this helps! Are you having problems with network connectivity or response time?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 08:43 AM
02-08-2002 08:43 AM
SolutionThis one will write to a file
#!/bin/sh
LANG=C
### The hostnames file is a file with all the hostsname you want
### to monitor in a column
HOSTNAME_FILE=hostnames
for host in $(cat $HOSTNAME_FILE)
do
ping $host -n 1 | grep -q '1 packets received'
if [ $? = 0 ]
then
echo "$host: OK"
else
echo "$host: FAIL" >> host_down.log
fi
done
This one will send you an email
#!/bin/sh
LANG=C
HOSTNAME_FILE=hostnames
for host in $(cat $HOSTNAME_FILE)
do
ping $host -n 1 | grep -q '1 packets received'
if [ $? = 0 ]
then
echo "$host: OK"
else
echo "$host: FAIL" | mailx -s "hostdown" richard
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 08:46 AM
02-08-2002 08:46 AM
Re: help with Cron job
#!/bin/ksh
# script: /usr/local/bin/ping_node
remote_node=xxx.xxx.xxx.xxx # ip address here
echo date
/usr/sbin/ping $remote_node -n3
exit $?
and launch it from cron like this:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/ping_node >> /var/tmp/ping_node.log 2>&1
please keep in mind I've not tested this, caveat emptor and all that.
HTH
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 08:59 AM
02-08-2002 08:59 AM
Re: help with Cron job
Thanks for your fast replies, and great info.
The purpose of the cron job is to monitor a line. There is 2 nodes that I have to ping, andhave been getting complaints about. i just want to have a log with line info, by sending different size packets across, and seeing what the connection is.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 09:00 AM
02-08-2002 09:00 AM
Re: help with Cron job
#!/usr/bin/sh
PATH=/usr/sbin/ping:/usr/bin/:${PATH}
export PATH
Thoose paths always get you when you are doing cron scripts.
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 09:02 AM
02-08-2002 09:02 AM
Re: help with Cron job
you can have this entry,
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/sbin/ping host_name -n count >/your_log_file 2>&1
you can set the count as 5 so that the ping is tried 5 times and then it exits.
Hope this helps.
regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 09:03 AM
02-08-2002 09:03 AM
Re: help with Cron job
0,5,10,15,20,25,30,35,40,45,50,55 * * * * ping host_name -n 2 >> logfile 2>&1
So that both stderr and stdout go to the logfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2002 07:04 PM
02-20-2002 07:04 PM
Re: help with Cron job
03 11 * * * /usr/bin/ok >> /home/pin/ok.log 2>&1
0,5,10,15,20,25,30,35,40,45,50,55 * * * * ping 202.96.232.8 -n 2 >> /home/pin/ping.log 2>&1
/usr/bin/ok is a shell script
i find second mission is done,and i can find ping.log,but first mission is not done,i cant find ok.log.
why?