![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| error in running shell script in cron | sari | Shell Programming and Scripting | 3 | 04-16-2008 04:09 AM |
| Is it possible to have more than one Cron in shell script? | Yamini Thoppen | AIX | 4 | 12-17-2007 03:23 AM |
| Problem with scheduling a shell script on cygwin using cron | shash | UNIX for Dummies Questions & Answers | 4 | 08-09-2007 06:08 PM |
| executing shell script from the cron | abNORMal | HP-UX | 2 | 06-15-2006 02:54 PM |
| gzip in shell script called by cron | hbau419 | Shell Programming and Scripting | 2 | 02-05-2002 07:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Shell script & cron
Hi everybody!
I'm struggling against a script that won' t work right in a cron job this is my script: Code:
cat serverlist | while read arg
do
if [ -n $arg ]
then
echo "$arg"
ping -c 4 $arg >> /dev/null
if [ $? != 0 ]
then
msg_body="msg_subst"
host=`nslookup $arg | grep name | sed 's/.*name = //'`
cat message | sed "s/srv/$arg - $host/" > msg_subst
cat admins | while read line
do
if [ -n $line ]
then
echo "$line"
mail -s Servizio_controllo_server $line < "$msg_body"
fi
done
fi
fi
done
I have tried anything on it, but nothing helped. Thank you for the help and sorry for my english!! |
|
||||
|
First you should put the full path to serverlist, as cron wouldn't know where the file resides. See if this fixes it.
You are probably running it from the path where the file exists and that is why it works fine when manually running it. |
|
||||
|
The matter is that the script fully works even when launched in cron.
The focus problem is that the ping command returns always a non-zero value and the then block is always executed. This bug only occurs when i run the script from cron. P.S. my O.S. id FreeBSD 6.2 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|