The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cron job starts new cron proccess ron76 SUN Solaris 3 05-12-2008 02:07 AM
AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log Keith Johnson AIX 0 01-09-2008 08:32 PM
AIX - Cant ping Netghost AIX 1 10-03-2006 07:38 PM
ping csaunders AIX 1 04-24-2005 06:54 PM
ping -t jaber87 Shell Programming and Scripting 8 04-17-2004 01:58 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-28-2002
Trusevich Trusevich is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 6
ping from cron

Hello

I wrote a shell script to poll network. It works fine from command line, but doesn't want to work from cron.
To clarify the problem, I wrote simple test file (test.ksh):
ping -c1 -q 172.27.38.2 > /path/res.log

when I do:
>ksh test.ksh

it works fine, and res.log populated with ping info.
but when I'm calling it from cron:
29 15 * * * ksh /path/test.ksh

it creates res.log with 0 size and that's it.
Why doesn't it work from cron?

Thanks,
Vlad
  #2 (permalink)  
Old 02-28-2002
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
You may want to add...

>/tmp/test.ksh.err 2>&1

...to the end of your cron job line.
This may give you some hint as to why
the shell script is not working.

Sometimes, you need to specify the full path
name to commands when running under cron as
they may not get a full environment set when
the execute.

In your shell try...

!#/bin/ksh
/bin/ping -c1 -q 172.27.38.2 > /path/res.log
# assuming ping is in /bin

Your cron like...
29 15 * * * ksh /path/test.ksh >/tmp/test.ksh.err 2>&1
  #3 (permalink)  
Old 03-01-2002
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 500
This is how we ping other boxes to ensure their up and running.
Nb: This is run on a SCO Unix box.

Script:
Code:
# more /usr/users/operator/check_rcmd
if [ `rcmd $1 hostname | grep someweb.com` ]
then
  echo OK
else
  mailx -s "Unable to access SomeWeb server $1" ops@somedomain.com <<END
`hostname` cannot perform remote commands on $1
This may effect the ability to do bookings on $1
Follow TVL escalation procedure to resolve
END
fi
#

From Cron:
Code:
# Check rcmd is availble.  Test for situation where corruption of the
# authorisation database was preventing remote access 
10,40 * * * * /usr/users/operator/check_rcmd 168.153.251.80 > /dev/null 2>&1

Hope that helps some.
  #4 (permalink)  
Old 03-01-2002
Trusevich Trusevich is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 6
Thanks

You were right! it was path to ping should be /sbin/ping instead of just ping! how stupid of me!

Thanks guys
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0