php - nohup 为什么退出终端也就退出了,怎么解决呢
高洛峰
高洛峰 2017-04-17 17:10:38
0
7
460

例如我这样让其放置后台

nohup php index.php &

然后 jobs

jobs [3] - running nohup /home/pubsrv/php-5.6.15/bin/php ~/tools/douban/localBanBrush.php 2>&1 [4] + running nohup /home/pubsrv/php-5.6.15/bin/php ~/tools/douban/localBanBrush.php 2>&1

现在都还在,可是我退出终端后 ,下次登录可就没了。。
没了: 进程号木有,直接ps不到,同样的,程序是死循环 ,需要我手动才能关闭,我就测试退出进来它就关闭了,排除程序问题

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all (7)
阿神

There is a missing symbol after

: &

For example:

nohup sh /usr/local/services_data/elasticsearch-head.sh > /dev/null 2>&1 &

After running the nohup command, click Auto to see if the program can run in the background. If it doesn't work, there will be a pop-up message, just like yours.

    Ty80

    The standard output of the process defaults to the current session. If the session is closed, an error will occur. Standard output should be redirected to /dev/null

      大家讲道理

      1. You can use the process number to check whether the suspended process really exited.
      2. If it exited, you need to check your program log to see where your program exited.

        大家讲道理

        cat nohup.out Take a look. If there is no such file, it means you closed the terminal before nohup finished running. Of course not.

          Peter_Zhu

          Use ps -aux|grep xxx to find

            伊谢尔伦

            I have encountered this before. It is related to the SSH terminal you are using. You can try it by changing to the original bash.

              左手右手慢动作

              I usesetsid /usr/local/php/bin/php ~/shua3.php > /dev/null &

                Latest Downloads
                More>
                Web Effects
                Website Source Code
                Website Materials
                Front End Template
                About us Disclaimer Sitemap
                php.cn:Public welfare online PHP training,Help PHP learners grow quickly!