Find the answer to your Linux question:
Results 1 to 4 of 4
inside /etc/ppp/ip-up.d i have this script that executes automatically when the interface ppp0 comes up. Code: #!/bin/sh echo "Checking if exist internet connection" ping -c 3 www google com if ...
  1. #1
    Just Joined!
    Join Date
    Mar 2011
    Posts
    13

    need to log the execution of script

    inside /etc/ppp/ip-up.d i have this script that executes automatically when the interface ppp0 comes up.

    Code:
    #!/bin/sh
    
    echo "Checking if exist internet connection"
    
    ping -c 3 www google com
    
    if [ $? -eq 0 ]; then
    
      echo "Starting to send & download email"
    
      echo "Flushing mail queue"
    
      /usr/sbin/postqueue -c /etc/postfix -f
    
      echo "Starting fetchmail"
    
      /usr/bin/fetchmail -v -f /etc/fetchmailrc -L /var/log/fetchmail.log
    
      echo "Checking mail queue and fetchmail process"
    
      while ! postqueue -p | grep -q empty && ps -C fetchmail > /dev/null; do
    
        echo "There is still mail in queue or fetchmail is still working"
    
        sleep 1
    
      done
    
      echo "Terminating the connection"
    
      killall wvdial
    
    fi
    
    echo "Internet connection not found"
    i need to see the output for debug of this script, how can i log this to /var/log/script.log everytime it runs automatically?

  2. #2
    Just Joined!
    Join Date
    Jan 2008
    Posts
    17
    You could add >>/var/log/script.log to each line that produces output.

  3. #3
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,100
    That works, but is cumbersome.

    Redirecting stdout/sterr for the whole script may be better
    http://tldp.org/LDP/abs/html/x17784.html#REASSIGNSTDOUT
    You must always face the curtain with a bow.

  4. #4
    Just Joined!
    Join Date
    Jan 2008
    Posts
    17
    Nice! I knew that was possible but I didn't know how to do it. Thanks for the link!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...