note 115206 deleted from function.exec by cmb

From: Date: Sun, 24 Nov 2019 08:43:17 +0000
Subject: note 115206 deleted from function.exec by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213202@lists.php.net to get a copy of this message
Note Submitter: jbb5044 at gmail dot com ---- If you're trying to run something in the background on a system that uses systemd for its init, use the systemd-run utility to start your program in the background. systemd-run will run the command in a transient unit file so that you can query its status with systemctl and view its log with journalctl. <?php $lastline = exec('systemd-run --unit=my_unit_name /path/to/my/long_running_program arg1 arg2', $output, $exitval); ?> systemd-run returns immediately, launching your application for you and keeping track of it, so you don't need to worry so much about a forgotten process running on your server. From here you can query its status with <?php $lastline = exec('systemctl status my_unit_name', $output, $exitval); ?> And see its log with <?php $lastline = exec('journalctl -u my_unit_name', $output, $exitval); ?>

« previous php.notes (#213202) next »