任务计划2

[root@localhost app]# cat /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

MAILTO=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

# | 
|  |  |  |

 * 
*  *  *  *
root cron.sh

@reboot root touch /app/reboot.log

You have new mail in /var/spool/mail/root

 

 

 

[root@localhost ~]# cd  /etc/cron

cron.d/       cron.daily/   cron.deny    
cron.hourly/  cron.monthly/
crontab       cron.weekly/ 

[root@localhost ~]# cd  /etc/cron

cron.d/       cron.daily/   cron.deny    
cron.hourly/  cron.monthly/
crontab       cron.weekly/ 

[root@localhost ~]# cd  /etc/cron.d

[root@localhost cron.d]# ls

0hourly 
raid-check  sysstat

[root@localhost cron.d]# cat 0hourly

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

01 * * * * root run-parts /etc/cron.hourly

[root@localhost cron.d]# which run-parts

/usr/bin/run-parts

[root@localhost cron.d]# rpm -qf  /usr/bin/run-parts

crontabs-1.10-33.el6.noarch

[root@localhost cron.d]#

 

[root@localhost cron.d]# ll /etc/cron

cron.d/       cron.daily/   cron.deny    
cron.hourly/  cron.monthly/
crontab       cron.weekly/ 

[root@localhost cron.d]# ll
/etc/cron.hourly/

total 4

-rwxr-xr-x. 1 root root 409 Nov 10  2015 0anacron

 

 

 

 

[root@localhost etc]# cd /etc/cron.d/

[root@localhost cron.d]# ls

0hourly 
raid-check  sysstat

[root@localhost cron.d]# cat 0hourly

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

01 * * * * root run-parts /etc/cron.hourly

 

 

[root@localhost cron.d]# cat
/etc/cron.hourly/0anacron

#!/bin/bash

# Skip excecution unless the date has
changed from the previous run

if test -r /var/spool/anacron/cron.daily;
then

   
day=`cat /var/spool/anacron/cron.daily`

fi

if [ `date +%Y%m%d` = “$day” ];
then

   
exit 0;

fi

 

# Skip excecution unless AC powered

if test -x /usr/bin/on_ac_power; then

   
/usr/bin/on_ac_power &> /dev/null

   
if test $? -eq 1; then

   
exit 0

   
fi

fi

/usr/sbin/anacron –s

 

 

 

 

[root@localhost cron.d]# cd /etc/cron.d

cron.d/    
cron.daily/ cron.deny  

[root@localhost cron.d]# cd /etc/cron.daily/

[root@localhost cron.daily]# ls

cups 
logrotate  makewhatis.cron  mlocate.cron 
prelink  readahead.cron  tmpwatch

[root@localhost cron.daily]# whatis rm

rm                   (1p)  – remove directory entries

rm                   (1)  – remove files or directories

 

 

 

[root@localhost ~]# which crontab       //  普通用户定义计划任务需要借助这个工具实现

/usr/bin/crontab

You have new mail in /var/spool/mail/root

 

 

 

[root@localhost ~]# crontab -e -u fsy

* * * * * 
wall fsycron

 

[root@localhost cron]# cd /var/spool/cron/

[root@localhost cron]# ls

Fsy

 

 

[root@localhost cron.daily]# which crontab

/usr/bin/crontab

[root@localhost cron.daily]# ls  /usr/bin/crontab

/usr/bin/crontab

[root@localhost cron.daily]# ll  /usr/bin/crontab

-rwsr-xr-x. 1 root root 51784 Nov 10  2015 /usr/bin/crontab

 

 

 

[root@localhost cron]# crontab  -l                   // 查看计划任务

no crontab for root

 

[root@localhost cron]# export  EDITOR=vim

[root@localhost cron]# crontab -e -u fsy

 

 

[root@localhost cron]# crontab  -r           
//
删除所有的计划任务

[root@localhost cron]# ls /var/spool/cron/      // 相当于删除这个目录里的所有文件

Fsy

 

 

[root@localhost cron]# cat /var/log/cron

 

 

[root@localhost cron]# vim /etc/cron.deny

[root@localhost cron]# cat /etc/cron.deny

Fsy

 

[fsy@localhost app]$ crontab -e

You (fsy) are not allowed to use this
program (crontab)

See crontab(1) for more information

 

 

[root@localhost cron]# echo >
/etc/cron.deny

 

 

[root@localhost ~]# grep -E ‘^(S|M)’  /proc/meminfo

MemTotal:        1004140 kB

MemFree:          241724 kB

SwapCached:            0 kB

Mlocked:               0 kB

SwapTotal:       4095996 kB

SwapFree:        4095996 kB

Mapped:            56584 kB

Shmem:              2924 kB

Slab:             131392 kB

SReclaimable:      62108 kB

SUnreclaim:        69284 kB

原创文章,作者:fsy,如若转载,请注明出处:http://www.178linux.com/75860

(0)
fsyfsy
上一篇 2017-05-15 21:35
下一篇 2017-05-15 21:40

相关推荐

  • Keepalived介绍 , 配置说明 , 及实际应用

    1. Keepalived介绍 Keepalived是一个基于VRRP协议来实现的服务高可用方案,可以利用其来避免IP单点故障,类似的工具还有heartbeat、corosync、pacemaker。但是它一般不会单独出现,而是与其它负载均衡技术(如lvs、haproxy、nginx)一起工作来达到集群的高可用。 1.1 VRRP协议 VRRP全称 Virt…

    Linux干货 2016-11-04
  • 马哥教育网络20期+第7周练习博客

    1、创建一个10G分区,并格式为ext4文件系统;    (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;    (2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; [root@7b ~]#&nbsp…

    Linux干货 2016-07-24
  • 网络基础知识

    网络基础知识: 网络设备 TCP/IP协议 ARP协议 网络设备:     HUB集线器: 工作在物理层,没有学习能力,作用在于把各种节点汇聚在以它为中心的节点上,同时也有传输数据的作用,由于没有学习能力,只能以广播的形式将数据发送给与它相连的所有节点。 特点:共享带宽,半双工     &…

    Linux干货 2016-09-02
  • Http请求流程

    1、http请求流程 1.连接 当我们输入这样一个请求时,首先要建立一个socket连接,因为socket是通过ip和端口建立的,所以之前还有一个DNS解析过程,把www.mycompany.com变成ip,如果url里不包含端口号,则会使用该协议的默认端口号。 DNS的过程是这样的:首先我们知道我们本地的机器上在配置网络时都会填写DNS,这样本机就会把这个…

    Linux干货 2017-02-13
  • 计算机基础知识及服务器介绍

    现代计算机组成 根据冯·诺依曼结构体系计算机有五大部件组成: 运算器、控制器、存储器、输入设备、输出设备 CPU=运算器+控制器 运算器由算术逻辑单元(ALU)、累加器、状态寄存器、通用寄存器组等组成。 算术逻辑运算单元(ALU)的基本功能为加、减、乘、除四则运算,与、或、非、异或等逻辑操作,以及移位、求补等操作。 运算器只能进行二进制运算、逻辑运算 控制器…

    Linux干货 2016-06-09
  • 初学Linux的感受

    我是马哥25期的学员,之前从来没有接触过Linux,近几天学习Linux下来,收获很多,懂了一些基本命令,以及安装Linux系统. 我知道从一个什么也不懂的小白变成站在云端的大神,这之间需要付出多少的努力和汗水.开学典礼有幸见到马哥本人,也见到 我的授课教师老王,之前看到两位上课的视频,诙谐幽默,我很喜欢! 但愿我这四个月痛并快乐着. 努力,然后看到胜利的曙…

    Linux干货 2017-07-11