简体   繁体   中英

Running a php process on startup in Ubuntu

I'm in a school project and we use a process of collecting tweets through a stream set up with PHP. I usually run it in background through the terminal with a command like: nohup ./mystream.php 2>&1 &

This stream is supposed to be on at all times and thus I would like to make sure that this process starts up whenever the system reboots. How would I do that in Ubuntu?

You would make it part of a script that runs doing startup. We have done this with things like Upstart which replaces the sbin/init/ daemon. Here is an example script -

start on filesystem and net-device-up IFACE=eth0
respawn

exec /usr/bin/php -f /path/to/your/process.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM