-1

I want to run some php file in background and monitor them , what is the best option for me ?

I have used nohup , but it is really simple an can not monitor processes well

I need only monitor which process is still alive , automatically restart , CPU usage or any useful info

Ata
  • 101
  • 2

2 Answers2

1

I would recommend you to deploy monit what is a nice utility to manage and monitor processes, files and much more. You can monitor a process and its CPU usage with such simple configuration then:

check process your_php_script
        matching "your_php_script"
        start program = "/home/user/bin/your_php_script
        stop program = "/usr/bin/pkill your_php_script
        if cpu usage > 80% for 5 cycles then restart

Briefly, it will check for a running process "your_php_script". If it's not running it will start it and if it uses more than 80% of CPU for more than 5 cycles it will restart the process (cycle/polling interval is configured in monit daemon configuration file in /etc/monit.conf).

dsmsk80
  • 5,817
  • 18
  • 22
0

You can try out Pandora FMS monitoring software. With this tool you can perform processes and services monitorization and also some basic monitoring (CPU, Disk, RAM,...). In fact I think that there are some plugins developed for the Apache Server in the module library.