Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Debian 6.0.6. I edited root crontab a few days ago to add this line:

00,10,20,30,40,50 * * * * /root/Scripts/ >> /var/log/con_switch_diario.log 2>&1

I'm connecting to this linux server using Putty. Meanwhile Putty console is opened and connected a line is generated inside the file "con_switch_diario.log" every 10 minutes (i.e., the script is running).

But when I closed that Putty console (i.e., the ssh connection is finished) and then I reopened it, I found that there aren't entries on that log file during that lapse of time. I did some tests and I found that when the console is closed the script is not executed by crontab.

The content of the script is this:



IPfirewall=`traceroute -m 3 $IPcorreo | grep $IP1`

if [ $? -eq  0 ]
  echo "$IPfirewall: `date`"

  ploss=$(ping -q -w30 $IPcorreo | grep -o "[0-9]*%" | tr -d %) > /dev/null 2>&1

  if [ "$ploss" -gt "$maxPloss" ] 
    /usr/bin/expect /root/Scripts/delete.exp
    sleep 60   
    echo "Switch Email: `date`" | mail -s System
  traceroute -m 3 $IPcorreo | grep $IP2

I don't know how could I fix this problem. Thank you for your help.

PS: in the same server, inside crontab I have defined others scripts... all they are running ok everyday. The only difference I found between them is they use


instead of


But even if I change it on my script to use bash I still have the same problem.

share|improve this question

migrated from Dec 24 '12 at 4:31

This question came from our site for professional and enthusiast programmers.

the problem is fixed. The cause was this line

ploss=$(ping -q -w30 $IPcorreo | grep -o "[0-9]*%" | tr -d %) > /dev/null 2>&1

once I changed it to

ploss=`ping -q -w30 $IPcorreo | grep -o "[0-9]*%" | tr -d %`

everything began to work fine.

share|improve this answer

You must log in to answer this question.