每天在特定时间执行shell脚本

Sin*_* Sh 14 linux shell cron debian sh

我有一个简单的shell脚本,只检查目录的内容,如果在白天添加任何内容,则将其复制到备份文件夹.我想在每天结束时执行这个脚本(让我们假设在23:55).

此脚本驻留在其上的系统(Debian)始终打开(服务器类型)

我怎样才能做到这一点?

Kur*_*den 22

要添加crontab作业,请在UNIX/Linux shell提示符下键入以下命令:

$ sudo crontab -e
Run Code Online (Sandbox Code Playgroud)

添加以下行:

1 2 3 4 5 /path/to/script
Run Code Online (Sandbox Code Playgroud)

哪里

1: Minutes (0-59)
2: Hours (0-23)
3: Days (1-31)
4: Month (1-12)
5: Day of the week(1-7)
/path/to/script - your own shell script
Run Code Online (Sandbox Code Playgroud)

在你的情况下,它将是:

55 23 * * * /path/to/yourShellScript
Run Code Online (Sandbox Code Playgroud)


Par*_*per 13

您想使用编辑crontab文件

crontab -e
Run Code Online (Sandbox Code Playgroud)

然后你要添加

55 23 * * * COMMAND TO BE EXECUTED
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请查看此内容