【问题标题】:Cpanel CronJob several days of the weekCpanel CronJob 一周中的几天
【发布时间】:2015-08-06 06:58:02
【问题描述】:

我是 cron 作业的新手,我想在一周中的几天运行一个脚本

我确实创建了一个 CronJob,但它昨晚没有运行。
我想在周日到周四每晚 00:10 执行脚本

所以我将其添加为 Job
10 00 * * 0,1,2,3,4 execute.php

谁能告诉我我做错了什么?

【问题讨论】:

  • “昨晚没跑”;除了昨天,它有没有运行过?
  • 不,完全不是。如果我直接接近它,我知道脚本有效。我只想让 cronjob 加载页面,以便脚本执行
  • 告诉我更多关于你的系统的信息。操作系统?设置此 cron 的文件夹/文件?等等。也许您缺少 bin 和用户名,但这取决于系统。试试,例如:10 00 * * 0,1,2,3,4 root /usr/bin/php execute.php
  • 服务器运行Linux,文件夹:/public_html/xxx.nl/execute.php
  • 尝试删除root:* * * * * /usr/bin/php /public_html/xxx.nl/execute.php。无论如何,我认为您的服务器上有一个根文件夹/public_html。可能完整路径不同,例如/home/user/public_html 或/var/www/public_html。试着找出来。

标签: cron cpanel


【解决方案1】:

将其设置为每天运行,然后将其添加到脚本的顶部

if (date('l') == 'Friday' || date('l') == 'Saturday') exit;

这样它甚至不会做任何事情,除非它是你需要的一天,并且不会让你头疼。

【讨论】:

  • 这是一个 PHP 解决方案,我正在寻找一个 cronjob 解决方案
  • 还不错,但仍在寻找 cronjob thnx!
【解决方案2】:

shell 上的 root 用户(WHM/Cpanel over Centos)

# crontab -e  #Edit cron jobs for user root

10 00 * * 0,1,2,3,4  /usr/local/cpanel/3rdparty/bin/php /full/path/to/execute.php >/dev/null 2>&1  #If not like report to email

用户面板 带有外壳访问权限

$ crontab -e  #Edit cron jobs for user

10 00 * * 0,1,2,3,4  /usr/local/cpanel/3rdparty/bin/php /full/path/to/execute.php >/dev/null 2>&1  #If not like report to email 

or

10 00 * * 0,1,2,3,4  /usr/bin/php /full/path/to/execute.php >/dev/null 2>&1  #If not like report to email

没有 shell 访问权限

Enter Cpanel and go to Cronjobs.
Put your tiem on each text input area.
Put your job 10 00 * * 0,1,2,3,4  /usr/local/cpanel/3rdparty/bin/php /full/path/to/execute.php >/dev/null 2>&1  #If not like report to email

说明

/usr/local/cpanel/3rdparty/bin/php 为 WHM/Cpanel 函数编译的 PHP。

/usr/bin/php 正常Cpanel安装使用的PHP

如果您的服务器使用了其他路径,例如,具有多个 PHP 版本的 Candlinux。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-30
    • 2013-12-17
    • 2011-09-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多