Skip to content

SSH: how to run a PHP script in background forever in Linux (CentOS) ?

Ayyaz Zafar1 min read

If you want to run a PHP script in the background forever through SSH then follow these steps:

If you are using a SSH terminal (PuTTY) then directly run following command:

Text
// Notice '&'; that operator will help to run this script forever.php server.php &// make sure that you are in the root directory of server.php

Now your script is running in background and will keep running indefinitely even after closing terminal.

To check if your script is running or not You can run following command:

Text
ps aux | grep server.php

Latest tutorials

All 754 →

Get new tutorials by email

One email when something new is published. Unsubscribe anytime.

Written by Ayyaz Zafar, full-stack developer for 15+ years. Work with me