gpt4 book ai didi

linux - 关于 Cron 的困惑

转载 作者:太空宇宙 更新时间:2023-11-04 04:38:10 25 4
gpt4 key购买 nike

这是我第一次为 cron 作业编写脚本。

我在 shell 中编写了代码(它可以工作),并且我正在尝试为 cron 设置它。这是我的问题。如何设置 cron?我应该写吗10 * * * */home/workstation/deleter.sh (我希望它每 10 分钟运行一次)就在 #!/bin/sh 下面吗?我将如何执行它? (deleter.sh 通过 chmod 获得权限)man 1 crontab 返回“手册第 1 节中没有 crontab 条目”我现在真的很迷失和困惑。如果有人知道如何设置 cron 请告诉我!!

提前致谢

#!/bin/sh

counter=0
logloc=/home/ServerLogs
backup=/home/test
## Reads the location of the file systems that needs to be investigated from location.txt
## and save it into an array
while read -r line; do
Unix_Array[${counter}]=$line;
let counter=counter+1;
done < location.txt
## Reads Email recipients and save it into an array
More code continues from here......

最佳答案

以下命令将打开您环境的文本编辑器并加载 crontab:

crontab -e

您的 crontab 条目大部分是正确的。为了让您的脚本每十分钟运行一次,应将其更改为:

*/10 * * * * /home/workstation/deleter.sh

您指定的条目将在每小时的第 10 分钟运行脚本。

关于linux - 关于 Cron 的困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12646321/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com