I have a daemon script in /etc/init.d that performs some background packet logging using the tcpdump command. The script starts up fine using an interactive shell using sudo /etc/init.d/packetlog start

When I execute the same command through my fabric script (below) the command returns successfully but the process is not running.

def startpacketlog():
    sudo(r'/etc/init.d/packetlog start')

Further to this, the service does not start automatically on boot as I had expected.

Some tips for troubleshooting this would be appreciated

The script is here and is modified from this original

Update This seems to be a general problem with starting any service on this host using fabric. When starting the apache2 service I get the same problem. I can stop the service using fabric successfully though.

Update 2 After re-reading the documentation and some experimentation the following change fixed the problem. (This disables the remote pseudo-terminal, whatever that is)

def startpacketlog():
    sudo(r'/etc/init.d/packetlog start',pty=False)
  • might help if you post the fabric line you are using
    – Mike
    May 17, 2011 at 16:07
  • good point - I've added it now
    – rupello
    May 17, 2011 at 17:20

1 Answer 1


When you invoke an init script directly, your current environment can "leak" into the init script.

Test your init script using the appropriate system tools:

# Redhat/CentOS, and Ubuntu with upstart
sudo service packetlog start

# traditional method on Debian/Ubuntu 
sudo invoke-rc.d packetlog start

These will make sure the script is starting in a clean environment, identical to the one it would be in when started by init.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.