English 中文(简体)
将 shell 脚本排入 crontab 中
原标题:Scheduling shell script in crontab

我有一个 shell 脚本, 可以由 root 用户以这种方式运行 :

root@vivivid-15:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

它在 /root/ backup.sh 上。 现在,我如何在 crontab 上安排它每天早上1点执行?

0 1 * * * 根

但现在我不知道该如何执行命令了

最佳回答

您试过吗? 另外,小时字段中的“ 1” 表示上午1点, 而不是下午1点 。

0 1 * * * root /root/backup.sh

编辑: 将 13 (下午1时) 改为 1 (上午1时)。

问题回答

Crontab 格式:

MIN HOUR DAY MON WEEKDAY CMD

我不知道您是否需要定义什么用户, 您需要将其定义为在 Crontab 中运行的用户。 命令将作为使用 crontab - e 进行条目输入的用户运行。 要创建像 root 一样运行的 cron 进程, 要么作为 root 登录, 要么用 $sudo crontab - e 设置

我想你正在寻找 更类似这样的东西:

0 1 * * * /root/backup.sh




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...