连大神都必须掌握的Linux定时任务
2022/7/21 5:25:01
本文主要是介绍连大神都必须掌握的Linux定时任务,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、cron服务:
systemctl status/start/stop crond
二、查看crontab帮助:
[root@localhost ~]# crontab --help crontab:无效选项 -- - crontab: usage error: unrecognized option Usage: crontab [options] file crontab [options] crontab -n [hostname] Options: -udefine user -e edit user's crontab -l list user's crontab -r delete user's crontab -i prompt before deleting -nset host in cluster to run users' crontabs -c get host in cluster to run users' crontabs -s selinux context -xenable debugging
指令解析:
三、使用者权限及定时任务文件:
四、定时任务指令的使用格式:
/etc/crontab 这个文件负责安排由系统管理员制定的维护系统以及其他任务的crontab
crontab基本格式:
* * * * * cmd 以上格式按顺序分别表示为: 分钟(00-59) 小时(00-23) 日(01-31) 月(01-12) 星期(0-6) cmd表示需要执行的脚本或命令例如:/bin/sh /root/syz.sh 注意: 每个*之间都存在空格 星期的0和7都代表星期日 日和周不要组合配置(否则很容易出错)
crontab 语法格式中特殊符号含义如下表:
五、实例
1、每天18点32分执行如下backup.sh脚本,注意单纯的echo,从屏幕上看不到任何输出,因为cron把任何输出都email到root的信箱了。
32 18 * * * /bin/bash /server/scripts/backup.sh
2、每隔8个半小时执行任务
30 */8 * * * /bin/bash /server/scripts/backup.sh
这篇关于连大神都必须掌握的Linux定时任务的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-30[译]漫画SELinux概念
- 2024-03-29linux 移动文件
- 2024-03-28linux .so file
- 2024-03-28Linux 磁盘管理
- 2024-03-28Linux学习笔记(十三)磁盘管理(一):磁盘分区
- 2024-03-26linux 创建 文件
- 2024-03-25使用SecureCRT对Linux vim进行颜色设置
- 2024-03-202019-2020-12 20199317 《Linux内核原理与分析》 第十二周作业
- 2024-03-20Linux运维的第二周总结
- 2024-03-13how to count number of directories in linux