作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个 php 脚本,它通过 http 读取一个文件(该文件在其他域上)。我想每天只阅读一次或两次这个文件,而不是每次刷新网站时都连接到它。除了使用 cron 之外还有其他方法吗?我不想使用 cron,因为我更喜欢在脚本本身中设置此行为......所以它很灵活,所以我可以在任何地方使用它而无需每次都设置 cron。谢谢
最佳答案
我过去在无法访问 cron 时做过这种事情:
$lastRunLog = '/path/to/lastrun.log';
if (file_exists($lastRunLog)) {
$lastRun = file_get_contents($lastRunLog);
if (time() - $lastRun >= 86400) {
//its been more than a day so run our external file
$cron = file_get_contents('http://example.com/external/file.php');
//update lastrun.log with current time
file_put_contents($lastRunLog, time());
}
}
关于php - 如何以一定的时间间隔运行 PHP 脚本(例如每天一次)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/865381/
我正在尝试开发右边框/Angular 具有特定 Angular (30°) 的表格。我见过一些类似的解决方案,但它们都无法在一定程度上发挥作用。如果我想从 30° 改变到 20°,我不想花太多力气。
我是一名优秀的程序员,十分优秀!