How can I run a 24/7 PHP process on a server that sends emails every minute without needing an open browser?
I have implemented a persistent PHP process by creating a custom daemon that runs entirely through the command line without relying on a web browser. This was achieved by writing a self-contained script with robust error handling and a continuous loop that runs indefinitely. Logs are maintained to monitor the process and ensure reliability. Additionally, I configured the script to restart automatically if it fails. This solution is effective, scalable, and minimizes potential downtime while handling repeated tasks such as sending emails.
hey lucas, i used pcntl_fork to handle your email tasks in child processes. it lets you keep the main script runnng non-stop while the fork handles emails. keep an eye out for mem leaks tho.
hey lucas, have you tryed using a cronjob to run your php script every minute? its a pretty solid approach if u dont want a browser open. im curious, has anyone else used something like a daemon for continous backend tasks? would love to hear more ideas!
hey lucas, u could try a systemd service to run your php-cli script continuously. added a bit of setup but it kept my process alive 24/7 without needing a browser. works fine on my side
hey lucas, have u tried a supervisor-managed php cli inside a docker container? i testd that and its auto restart felt pretty robust. im curious, has any1 played with this setup for continous tasks?