douling1936 2011-05-13 22:21
浏览 170
已采纳

如何使用shell_exec从其路径中查找进程ID

I need to provide my users with a way to stop their cron task so that it can restart on its 5 minute cycle.

I think I need to use shell_exec to get the processes back and then kill the specific process. The only way I will be able to distinguish this process from the others running on the server are the paths i.e php /home/sconmod/public_html/**URN**/Includes/System/CronTask.php.

Does anyone know a way I can get the process ID of a process by matching the path?

Thanks.

  • 写回答

1条回答 默认 最新

  • douse8732 2011-05-13 23:08
    关注

    The usual way of dealing with this problem is a PID file. Write the cron job's process ID to a file in a known location when the job starts and delete the file when the job ends. If you need to kill the process before it ends, just read the PID out of the file and kill the process. You'll want to include some signal handling in the cron jobs so that they properly clean up their PID files though, you wouldn't want to send a SIGTERM to the wrong process just because someone left a stale PID file around.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程