码尚云_西安云计算培训_云计算运维培训机构

标题: shell脚本十个工作中常用的案例(8) [打印本页]

作者: 云客    时间: 2022-9-20 11:25
标题: shell脚本十个工作中常用的案例(8)

  1. #!/bin/bash
  2. cron_command="0 0 * * * /path/to/script.sh"
  3. (crontab -l ; echo "$cron_command") | crontab -
  4. echo "已添加定时任务:每天凌晨执行/path/to/script.sh"
复制代码


这个脚本使用crontab命令添加一个定时任务,每天凌晨执行指定的Shell脚本。







欢迎光临 码尚云_西安云计算培训_云计算运维培训机构 (http://www.mashangcloud.com/) Powered by Discuz! X3.4