每天在特定时间执行 shell 脚本
Execute a shell script everyday at specific time
我有一个简单的 shell 脚本,它只检查目录的内容,如果白天添加了任何内容,则会将其复制到备份文件夹中。
我想在每天结束时执行此脚本(假设在 23:55)。
此脚本所在的系统 (Debian) 始终在(某种服务器)上
我该怎么做?
我什么都不是,只是 linux 专家,但快速 Google 搜索得出以下结果:
watch -n <your time> <your command/script>
这应该可以解决问题。有关更多信息,请查看:http://www.linfo.org/watch.html
您想使用
编辑您的 crontab 文件
crontab -e
那你要加
55 23 * * * COMMAND TO BE EXECUTED
有关详细信息,请查看 this
sudo crontab -e
55 23 * * * some_shell_script.sh
查看 Cron task scheduler built in to Debian. Simply add an entry for your script to your crontab file (see: https://help.ubuntu.com/community/CronHowto)。
要添加 crontab 作业,请在 UNIX/Linux shell 提示符下键入以下命令:
$ sudo crontab -e
添加以下行:
1 2 3 4 5 /path/to/script
哪里
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
你的情况是:
55 23 * * * /path/to/yourShellScript
我有一个简单的 shell 脚本,它只检查目录的内容,如果白天添加了任何内容,则会将其复制到备份文件夹中。 我想在每天结束时执行此脚本(假设在 23:55)。
此脚本所在的系统 (Debian) 始终在(某种服务器)上
我该怎么做?
我什么都不是,只是 linux 专家,但快速 Google 搜索得出以下结果:
watch -n <your time> <your command/script>
这应该可以解决问题。有关更多信息,请查看:http://www.linfo.org/watch.html
您想使用
编辑您的 crontab 文件crontab -e
那你要加
55 23 * * * COMMAND TO BE EXECUTED
有关详细信息,请查看 this
sudo crontab -e
55 23 * * * some_shell_script.sh
查看 Cron task scheduler built in to Debian. Simply add an entry for your script to your crontab file (see: https://help.ubuntu.com/community/CronHowto)。
要添加 crontab 作业,请在 UNIX/Linux shell 提示符下键入以下命令:
$ sudo crontab -e
添加以下行:
1 2 3 4 5 /path/to/script
哪里
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
你的情况是:
55 23 * * * /path/to/yourShellScript