What is the comand to start a service?



  • I am looking to write something that will automaticly run a comand every X mins.

    For example ntop keeps stopping and i would like a way to make it restart if it crashes. I have done something similor in linux with a simple script (where the script ran as the service, and if the program crashed, the script would loop and would just restart the program and repeat)

    Does anyone know of any documentation for doing something like this on bsd, i have some linux experince but i have not used bsd at all.

    what is a service called on bsd?

    So i am looking for the comand to restart a service and how to create a new service. Thanks!



  • You may use crontab. If you need a interval which is less than 1minute (for example, regular check something in 20 seconds) you may use the http://cr.yp.to/daemontools.html. It's very easy!



  • Thanks!



  • What do i need to type to manualy restart a service from ssh?

    i looked for ntop in /etc/rc.d but it was not there. Is it in another location, or am i missing it?
    Thanks



  • To restart squid from the webGUI you may use
      https://<firewall_ip>/status_services.php?mode=restartservice&service=squid

    (Tab : / webGUI / Status / Services )

    You should read the php code in
      /usr/local/www/status_services.php
      /etc/inc/service-utils.inc

    I don't use ntop so I don't know extactly how to restart it.</firewall_ip>



  • is there a comand to stop services and start them. I do not want to use php, if i am going to use cron.
    Thanks



  • PHP script is a great idea of pfsense/monowall. Why dont' you use PHP for you jobs?

    Create `foobar.php' like

    
      // ...
      restart_my_services();
    ?>
    
    

    and run (as cron job)

    
    php /path/to/foobar.php
    
    


  • @bilbus:

    is there a comand to stop services and start them. I do not want to use php, if i am going to use cron.
    Thanks

    I think you could use 'kill'.
    http://www.freebsd.org/doc/en/books/handbook/basics-daemons.html

    To start simply use either service name or complete path to application, depending on if it's in the "path" in the system.
    You should see that logging on to the shell and typing 'set' I think.

    Cheers,


Log in to reply