【问题标题】:Cronjob doesn't run on Google Compute EngineCronjob 无法在 Google Compute Engine 上运行
【发布时间】:2017-08-11 10:03:50
【问题描述】:

我在 Google Cloud 的计算引擎上的一个实例中设置了一个 cron 作业。

假设每天早上 7:47 运行。但是,每次我检查文件是否已在 7:48 执行时,它都不起作用。

helloworld.sh 文件的代码在这里

echo "helloworld" + "$(date)" > helloworld.txt

我已将检查设置为 root 并将 cron 作业设置为 root 仍然没有。有什么想法吗?

【问题讨论】:

    标签: google-app-engine cron crontab google-compute-engine


    【解决方案1】:

    cron 作业是错误的,因为您需要在命令中使用绝对路径。试试:

    /bin/bash /home/username/helloworld.sh
    

    【讨论】:

    • 还是有问题。我检查了 cron 状态,它处于活动状态。
    • 我也面临同样的问题。 service crond status 即使在 sudo service cron start 之后也会给出 Unit crond.service could not be found.
    • @mathiasrw,您需要检查服务状态的命令是:service cron status。如果您将服务称为:crond,将找不到该服务。
    猜你喜欢
    • 2020-09-23
    • 2013-12-24
    • 1970-01-01
    • 1970-01-01
    • 2016-06-19
    • 2018-05-07
    • 1970-01-01
    • 2018-03-26
    相关资源
    最近更新 更多