【问题标题】:how to set up cron in ubuntu from root?如何在 ubuntu 中从 root 设置 cron?
【发布时间】:2013-10-12 18:03:28
【问题描述】:

我无法在 ubuntu 服务器中从 root 设置 cron。

当我尝试使用:- sudo crontab -e 它给了我错误“root 没有 crontab - 使用一个空的 888"

请帮帮我。我需要每分钟设置一次 cron。

【问题讨论】:

    标签: unix ubuntu cron


    【解决方案1】:

    假设您在 /home/username/hello.sh 中有一个 hello.sh,代码如下

    #!/bin/bash
    echo "Hello World!!!"
    

    创建一个文件 /etc/cron.d/hellocron 并将下面的行放入其中

    * * * * * root /home/username/hello.sh
    

    cron 将每分钟运行 /home/username/hello.sh,在本例中,它将打印字符串“Hello World!!!”每分钟。

    【讨论】:

      【解决方案2】:

      查看 /etc/cron* 中的目录以添加系统范围的 cron 作业。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-09
        • 2016-10-21
        • 2013-02-24
        • 2020-08-09
        • 1970-01-01
        • 1970-01-01
        • 2019-03-26
        • 2015-10-05
        相关资源
        最近更新 更多