php - 如何在 Dreamhost 中使用 php 设置 cron?
问题描述
我想知道如何让这个 cron 工作在 Dreamhost 服务器中工作:
$cron = '15 * * * * /usr/local/php71/bin/php '. ' /home/username/run.php >> /home/username/cron.out';
try{
$output = shell_exec('crontab -l');
$job = '';
$cronfile = '/home/username/tmp/crontab.txt';
file_put_contents($cronfile, " ");
$job = $output . ' ' . $cron;
file_put_contents($cronfile, $job . PHP_EOL, FILE_APPEND);
echo exec('crontab ' . $cronfile);
echo 'Successful cron job task';
}catch(Exception $ex){
error_log("Errors while setting up cron $ex");
}
这是 run.php 中的内容:
<?php
error_log("Called from cron job");
?>
但我没有看到来自 run.php 的任何日志。我应该怎么做才能正确配置并成功完成 cron 作业?
解决方案
推荐阅读
- python - 在 Python 3.x 中将 for 循环转换为 while 循环
- elasticsearch - 如何在elasticsearch中配置“search.max_open_scroll_context”?
- flutter - 块流未正确更新
- mongodb - $match 和 $lookup 不适用于 mongodb 聚合
- reactjs - 如何在 React 应用程序中显示彩色 STL 文件
- node.js - I want to change value in object after specific time
- smtp - Gsuite SMTP 电子邮件未发送
- node.js - 无法在 $geoNear 聚合中使用线串
- image - applescript 查找不再在 Mac OS Mojave 下工作的壁纸图像
- list - 在 Kotlin 中,如何检查 List
包含一个或另一个数据类?