Run ping command every hour in backgrond


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run ping command every hour in backgrond
# 1  
Old 05-12-2017
Run ping command every hour in backgrond

Hi,
I have a VPN tunnel. It is going down occasionally. I need to run "/usr/sbin/ping 172.xx.xx.xx.xx" and it give mes output "172.xx.xx.xx is alive" and immediately after that VPN tunnel comes up.
Till we find permanent solution, I want this command to run in background, like every one hour. Should I simply have below entry in cronjob ?
Code:
0 * * * * /usr/sbin/ping 172.xx.xx.xx.xx

Or any other way ?
# 2  
Old 05-12-2017
I don't see an immediate problem except the strange IP format. What's the result if you install that crontab entry?
# 3  
Old 05-12-2017
It is not executing via crontab. I am root. ( I am giving actual IP, not xx.xx.). Just for testing purpose, I made it every minute
Code:
bash-3.2# crontab -l | grep -i ping
* * * * * /usr/sbin/ping 172.23.xx.xx > /tmp/ping_test
bash-3.2# cat /tmp/ping_test
cat: cannot open /tmp/ping_test
bash-3.2#

If I run command manually, I can see output in /tmp/ping_test
# 4  
Old 05-12-2017
Can't tell why it behaves as described. Is the path correct?
If I reproduce your setup, cron creates an (endlessly) pinging process every minute. You might want to limit the ping count so it stops after a few pings.
/tmp/ping_test is catable all the time. That error message I can't reproduce; all I get is cat: /tmp/pt: No such file or directory in case.
# 5  
Old 05-12-2017
Yes, path is correct. If I run it manually, it works
Code:
bash-3.2# crontab -l | grep -i ping
* * * * * /usr/sbin/ping 172.23.xx.xx > /tmp/ping_test
bash-3.2# which ping
/usr/sbin/ping
bash-3.2# cat /tmp/ping_test
bash-3.2# /usr/sbin/ping 172.23.xx.xx > /tmp/ping_test
bash-3.2# cat /tmp/ping_test
172.23.xx.xx is alive
bash-3.2#

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Run the script continously but mail once in 1 hour

Hi, I have a script written for monitoring the queue manager status continously. below is the script. QMGR=`dspmq | awk '{print $1}' | cut -f2 -d "(" | cut -f1 -d ")"` QMSTATUS=`dspmq | awk '{print $2}' | cut -f2 -d "(" | cut -f1 -d ")"` count=`dspmq | awk '{print $1}' | cut -f2 -d "(" | ... (5 Replies)
Discussion started by: Anusha M
5 Replies

2. Shell Programming and Scripting

Shell script to be run every one hour

How can we run shell script every one hour. Anyone having code unit for this? (1 Reply)
Discussion started by: Pratiksha Mehra
1 Replies

3. Shell Programming and Scripting

How to run a process continuously for an hour then stop?

Hi I have a shell script I would like to run it has to run twice a day every 5 seconds for an hour I can do this with cron but I was hoping there was an easier way. Is there a way to make a process sleep only at a certain time of day say between 1 and 2 pm? Or under certain conditions? Any help... (8 Replies)
Discussion started by: Paul Walker
8 Replies

4. Shell Programming and Scripting

To run a job for every one hour and ...

Hi, Someone please help me to run the script to maintain a Job: Which can be run for every one hour and should maintain the last two hours files only. It should delete the rest of the files in a dir. Please suggest me with the sample script. Thanks !! Reagrds, Rama (5 Replies)
Discussion started by: ramagore85
5 Replies

5. Shell Programming and Scripting

How to run script automatically every 12 hour once?

Hi ! all, I have once script to remove temporary cache and temporary xml files looks like this, as it is taking more space, I would like to run automatically every 12 hour once, and then I want to receive some log as acknowledgement #!/bin/sh echo "Removing logs and temp files (typically... (4 Replies)
Discussion started by: Akshay Hegde
4 Replies

6. Shell Programming and Scripting

How to convert 24 hour time to 12 hour timing?

Hi friends, I want to convert 24 hour timing to 12 hour please help me... my data file looks like this.. 13-Nov-2011 13:27:36 15.32044 72.68502 13-Nov-2011 12:08:31 15.31291 72.69807 16-Nov-2011 01:16:54 15.30844 72.74028 15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Discussion started by: nex_asp
13 Replies

7. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

8. Shell Programming and Scripting

To Run a job every hour without using crontab

Hi, Can anyone help me in finding how to run a specific job every hour without using crontab. Say for example i need to run a command ps -aux in the starting of every hour.. (3 Replies)
Discussion started by: glv
3 Replies

9. Shell Programming and Scripting

Run a script on the hour but only for 30mins

Hi All, I want to run a script on the hour during a 24 - hour period; easy enough cron will take care of that..however I want the script to only run for only 30mins.. so with the script it knows its 30mins are up so exits. any ideas? Any help, greatly appericated. Thanking you all... (2 Replies)
Discussion started by: Zak
2 Replies

10. Shell Programming and Scripting

long runnning processes more than one hour not able to see in ps -ef command

hi, We have one script ‘X' which invokes another script ‘Y'. Inside X we are checking if Y is active/running or not with ps command. But for cases when Y runs for more than 1 hour the ps command inside X returns that no Y process running. Can you please guide me if in UNIX any long running process... (4 Replies)
Discussion started by: shyam soni
4 Replies
Login or Register to Ask a Question