How to run a script in the background even the terminal is closed

Did you ever want to run a PHP script that you can left behind running even your close the terminal where you ran it? we can use nohup command

We have here an example how we can run a php script at background then it will keep on running even we log off on our terminal session.

the nohup can be used to avoid the termination of a process when logging off from a terminal or SSH session. but when you use only nohup  the ssh session will refuse to log off because it doesn’t want to lose the data from the background job you started so you need to include > /dev/null 2>&1 & so this IO streams will catch the data from the background process thus continuing the process after your logoff.