nohup在后台常驻运行php脚本
To run a PHP script in the background using nohup, you can follow these steps:
Navigate to the directory containing your PHP script: Open a terminal window and navigate to the directory where your PHP script is located.
Use the nohup command: Execute the following command, replacing my_script.php with the actual filename of your PHP script:
nohup php my_script.php &
Explanation of the command:
nohup: Stands for "no hangup," which means the process will continue to run even if you log out of the terminal session.php: Invokes the PHP interpreter to execute the script.my_script.php: The filename of your PHP script.&: Runs the command in the background and returns you to the prompt.Additional options:
>. For example, to redirect the output to a file named output.log, use:
nohup php my_script.php > output.log &
2>&1. For example, to redirect error output to a file named error.log, use:
nohup php my_script.php 2>&1 > output.log &
-C:
nohup php -C /path/to/working/directory my_script.php &
Monitoring the background process:
ps command to list running processes. Look for the php process associated with your script.
ps -ef | grep my_script.php
top command to view detailed information about running processes, including CPU and memory usage. Find the php process associated with your script and check its resource usage.Troubleshooting:
Remember that running scripts in the background using nohup can detach them from your terminal session, so you'll need to use other methods to monitor and manage them.
《无所畏惧》温莉的结局是什么
时间:2023-11-25
《无所畏惧》刘铭的结局是什么
时间:2023-11-25
《无所畏惧》罗英子和陈硕最后在一起了吗
时间:2023-11-25
《宁安如梦》 姜雪宁是如何设计让薛姝去和亲
时间:2023-11-25
《宁安如梦》薛姝为了不和亲做了什么
时间:2023-11-25
《宁安如梦》为什么姜雪蕙只能当侧妃
时间:2023-11-25