I developed a crawler in PHP that parse an URL with specific headers and put all URLs of content in the queue. It works fine.

I developed this code in a ubuntu 14.04 and I put a .conf file in /etc/init folder with this content:

# Info
description "Warm the varnish to get the list of products"
author      "Juanjo Aguilella"

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn limit 100 5

# Run the script
# Note, in this example, if your PHP script return
# the string "ERROR", the daemon will stop itself.
    [ $(exec /usr/bin/php -f /var/www/crawler.php) = 'ERROR' ] && ( stop; exit 1; )  
end script

It works fine in Ubuntu 14.04 and I can start and stop the daemon using "sudo service crawler start" and "sudo service crawler stop"

Now in production environment I have a Ubuntu 16.04 server and I put the same code on the same folder but when I try to start the service I receive the message "Failed to start crawler.service. Unit crawler.service not found"

Can you give me any help about it?


  • Missing php executable in /usr/bin/php ? Check the logs, you will have some information
    – Dom
    Jun 22, 2016 at 9:46
  • 2
    Ubuntu 16.04 uses systemd. Find out how that works, and make a crawler.service.
    – Halfgaar
    Jun 22, 2016 at 9:51

4 Answers 4


Adding to @Juanjo Aguilella Marés answer, and once you have copied/linked your script to /etc/systemd/system, you may want to automatically start it when the server starts:

sudo systemctl daemon-reload
sudo systemctl enable my_service.service
sudo systemctl start my_service.service

Source Digital Ocean

It is also a good idea not to run it as root. Just change the user line on your script:


I solved the problem:

a) Create a file crawler.service in /etc/systemd/system with this code:

Description=Crawler cache Service



my bash file contains a diferent executations on parallel to the same php file with this code:

php /var/www/tiendas.local.mediamarkt.es/crawler.php
sleep 0.1
    php /var/www/tiendas.local.mediamarkt.es/crawler.php
sleep 0.2
    php /var/www/tiendas.local.mediamarkt.es/crawler.php
sleep 0.3
    php /var/www/tiendas.local.mediamarkt.es/crawler.php
sleep 0.4
    php /var/www/tiendas.local.mediamarkt.es/crawler.php

the sleep between execitions es necessary to save the problem about the execution so fast of the service.

If you have any suggestion about the solution, please comment, I dont have a lot of experience in bash files and systemd files, but at the moment works fine.


The init system for 14.04 is upstart. The init system for 16.04 is systemd. You should convert your upstart script to a systemd unit file. There are plenty of other resources available too.


1]. To create a service go to /etc/systemd/system/

2]. Create a file of serviceName e.g chatSocket.service

3]. Put content to file as given bellow

Description=Your PHP Daemon Service
#Requires=mysqld.service memcached.service #May your script needs mysql or other services to run.
#After=mysqld.service memcached.service

ExecStart=/usr/bin/php -f /home/shrikant/workspace/app/Http/Controllers/server.php  2>&1> /dev/null #path to script
#ExecStop=/bin/kill -HUP $MAINPID
#ExecReload=/bin/kill -HUP $MAINPID


StandardOutput=null #If you don't want to make toms of logs you can set it null if you sent a file or some other options it will send all php output to this one.
StandardError=/home/shrikant/workspace/app/Http/Controllers/chatSocket.log #path to error log file

4]. Reload configuration by hitting:

sudo systemctl daemon-reload

5]. Enable service by default so when system start service will automatically start:

sudo systemctl enable my_service.service

6]. Start your service by using command below:

sudo systemctl start my_service.service

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .