Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 每天在特定时间执行shell脚本_Linux_Shell_Cron_Debian_Sh - Fatal编程技术网

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

Linux 每天在特定时间执行shell脚本,linux,shell,cron,debian,sh,Linux,Shell,Cron,Debian,Sh,我有一个简单的shell脚本,它只检查目录的内容,如果白天添加了任何内容,则将其复制到备份文件夹中。 我希望在每天结束时执行这个脚本(假设23:55) 该脚本所在的系统(Debian)始终处于运行状态(类似于服务器) 我怎么能做到这一点呢?我什么都不是,只是一个linux专家,但快速的谷歌搜索让我想到: watch -n <your time> <your command/script> watch-n 这应该能奏效。有关更多信息,请查看:您想使用 crontab -

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

该脚本所在的系统(Debian)始终处于运行状态(类似于服务器)


我怎么能做到这一点呢?

我什么都不是,只是一个linux专家,但快速的谷歌搜索让我想到:

watch -n <your time> <your command/script>
watch-n

这应该能奏效。有关更多信息,请查看:

您想使用

crontab -e
然后你要添加

55 23 * * * COMMAND TO BE EXECUTED

有关更多信息,请查看sudo crontab-e

55 23 * * * some_shell_script.sh

查看Debian内置的任务调度程序。只需将脚本条目添加到crontab文件(请参阅:)。

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

$ sudo crontab -e
添加以下行:

1 2 3 4 5 /path/to/script
在哪里

在您的情况下,它将是:

55 23 * * * /path/to/yourShellScript

首先阅读man crontab最有可能的是,已经有一个问题问了基本相同的问题。小心:如果你有一个长时间运行的脚本,你每天可能会运行许多实例。谢谢!我将使用您链接中的cronfile not found错误。你可能想更新一下
55 23 * * * /path/to/yourShellScript