You can just run the script (for example) every 12 hours.
You can either do this with the Linux command crontab -e
for the currently logged-in user or you can edit /etc/crontab
to run the script as a specific user.
With crontab -e
your line would look like this:
0 */12 * * * php /path/to/script.php >/dev/null 2>&1
As I said, in /etc/crontab
you can specify a specific user. It would look like this:
0 */12 * * * username php /path/to/script.php >/dev/null 2>&1
username
can be something like www-data. Just make sure the specified user has read/execute permissions on the script's file.
>/dev/null 2>&1
means that the output of the command is muted. You could also write the output into a file. There are also crontab-generators.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…