171204 8周1次课 linux任务计划cron
来源:互联网 发布:unity3d 机械仿真 编辑:程序博客网 时间:2024/06/07 15:27
- crontab -u、-e、-l、-r
- 格式:分 时 日 月 周 user command
- 文件/var/spool/cron/username
- 分范围0-59,时范围0-23,日范围0-31,月范围1-12,周0-6
- 可用格式1-5表示一个范围1到5
- 可用格式1,2,3表示1或者2或者3
- 可用格式*/2表示被2整除的数字,比如小时,那就是每隔2小时
- 要保证服务是启动状态
- systemctl start crond.service
[root@node73 ~]# cat /etc/crontab SHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=root# For details see man 4 crontabs# Example of job definition:# .---------------- minute (0 - 59)# | .------------- hour (0 - 23)# | | .---------- day of month (1 - 31)# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | | | | |# * * * * * user-name command to be executed
每天凌晨3点钟执行指定脚本,并且将正确重定向或错误的重定向到指定文件日志里
0 3 * * * /bin/bash /usr/local/sbin/123.sh >> /tmp/123.log 2>> /tmp/123.log每两个月的前10天且这十天内刚好为周二和周五的时间执行指定脚本
0 3 1-10 */2 2,5 /bin/bash /usr/local/sbin/111.sh >> /tmp/123.log 2>> /tmp/123.log
- 要保证服务是启动状态
[root@node73 ~]# systemctl start crond[root@node73 ~]# systemctl status crond● crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled) Active: active (running) since 一 2017-12-04 16:18:12 CST; 5h 25min ago Main PID: 1073 (crond) CGroup: /system.slice/crond.service └─1073 /usr/sbin/crond -n12月 04 16:18:12 node73 systemd[1]: Started Command Scheduler.12月 04 16:18:12 node73 systemd[1]: Starting Command Scheduler...12月 04 16:18:12 node73 crond[1073]: (CRON) INFO (RANDOM_DELAY will be scaled wit....)12月 04 16:18:13 node73 crond[1073]: (CRON) INFO (running with inotify support)12月 04 21:43:01 node73 crond[1073]: (root) RELOAD (/var/spool/cron/root)Hint: Some lines were ellipsized, use -l to show in full.[root@node73 ~]# ps aux | grep crondroot 1073 0.0 0.0 126252 1660 ? Ss 17:19 0:00 /usr/sbin/crond -nroot 8225 0.0 0.0 112668 972 pts/3 S+ 21:43 0:00 grep --color=auto crond
查看crondtab -l
[root@node73 ~]# crontab -l0 3 1-10 */2 2,5 /bin/bash /usr/local/sbin/111.sh >> /tmp/123.log 2>> /tmp/123.log1 10 * 2 * /usr/bin/find /tmp/ -type f -mtime +100 |xargs rm -f[root@node73 ~]# cat /var/spool/cron/root 0 3 1-10 */2 2,5 /bin/bash /usr/local/sbin/111.sh >> /tmp/123.log 2>> /tmp/123.log1 10 * 2 * /usr/bin/find /tmp/ -type f -mtime +100 |xargs rm -f
删除crondtab -r
Linux系统服务管理-chkconfig
- chkconfig --list
- chkconfig --level 3 network off
- chkconfig --level 345 network off
- chkconfig --del network
- chkconfig --add network
[root@node73 ~]# chkconfig --list注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。 欲查看对特定 target 启用的服务请执行 'systemctl list-dependencies [target]'。netconsole 0:关1:关2:关3:关4:关5:关6:关network 0:关1:关2:开3:开4:开5:开6:关
服务脚本
[root@node73 ~]# ls /etc/init.d/functions netconsole network README指定级别
[root@node73 ~]# chkconfig --level 3 network off[root@node73 ~]# chkconfig --list注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。 如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。 欲查看对特定 target 启用的服务请执行 'systemctl list-dependencies [target]'。netconsole 0:关1:关2:关3:关4:关5:关6:关network 0:关1:关2:开3:关4:开5:开6:关
•systemctllist-units --
all --type=service
[root@node73 ~]# systemctl list-units --all --type=service[root@node73 ~]# systemctl enable crond.service ###让服务开机启动
[root@node73 ~]# systemctl disable crond ####不让服务开机启动
[root@node73 ~]# systemctl status crond ####查看状态
[root@node73 ~]# systemctl stop crond ####停止服务
[root@node73 ~]# systemctl start crond ####启动服务
[root@node73 ~]# systemctl restart crond ####重启服务
[root@node73 ~]# systemctl is-enabled crond #####检查服务是否开机启动
Linux系统服务管理-systemd
•sys
阅读全文
0 0
- 171204 8周1次课 linux任务计划cron
- linux 任务计划 cron
- Linux cron计划任务
- Linux 计划任务 Cron
- Linux计划任务cron
- Linux任务计划cron
- linux中的cron(计划任务)
- linux cron实现计划任务
- Linux服务器Cron计划任务
- Linux下计划任务cron使用方法
- LINUX 的任务计划 at cron ancron
- linux计划任务cron学习笔记
- linux 计划任务 cron 全攻略
- Linux计划任务工具cron用法详解
- Linux计划任务工具cron用法详解
- Linux cron 计划任务日志跟踪
- Linux计划任务——cron服务
- Linux计划任务工具cron用法详解
- Fox And Two Dots
- JDK环境配置
- git基本概念
- 730. Count Different Palindromic Subsequences
- Linux-swap建置
- 171204 8周1次课 linux任务计划cron
- 一些简单程序的函数实现
- hdu 5542 Favorite Donut(字符串暴力)
- 网络传输协议小结
- 实验三:递归下降分析法
- codeforces 745C 联通
- java 集合泛型案例说明
- 穷举法
- bzoj1304 [CQOI2009]叶子的染色 dfs+树形dp