任务计划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

相关推荐

  • linux网络配置

    主要内容: ip地址以及子网划分 路由基本概念 网络配置工具:ifconfig,ip,netstat使用 网卡配置文件及修改 IP地址: 它们可唯一标识 IP 网络中的每台设备 v  每台主机(计算机、网络设备、外围设备)必须具有唯 一的地址 v IP地址由两部分组成:   &n…

    Linux干货 2016-09-07
  • 磁盘管理

    设备类型分为字符设备和块设备 主设备号用来标识设备类型,次设备号标识同一类型下的不同设备 硬盘设备命名: scsi,sata,sas,usb:/dev/sd 不同设备/dev/sda  /dev/sdb 同一设备不同分区:/dev/sda1,/dev/sdb2…… 硬盘: 一片磁盘的一面叫做盘面,一张盘片有两个盘面 每个盘面有一个磁头,最多有256…

    Linux干货 2016-08-30
  • N25–第十二周作业

    1、  请描述一次完整的http请求处理过程; (1)建立和处理连接:接收请求或者拒绝请求; (2)接收请求:接收来自于网络上的主机请求报文中对某特定的资源的一次请求的过程; (3)处理请求:对请求报文进行解析,获取客户端请求的资源及请求方法等相关信息 (4)访问资源:获取请求报文中请求的资源 (5)构建响应报文; (6)发送响应报文; (7)记录…

    2017-03-28
  •  编译安装步骤     大致过程:(源代码–预处理–编译–汇编–链接–执行)   第一步 下载安装开发工具“Development toos” 第二步 下载解压源代码包 仔细阅读“Install和 Read me” 第三步 使用./conf…

    Linux干货 2017-04-24
  • linux中数组的定义与使用

            我们常说,程序=指令+数据,往细一点的方向说,指令具体指的有哪些?数据又有哪些? 总结一下: 指令大概包括,编程语言中的语法关键字(如bash编程中的关键字有for,while,case,if,until,continue,break),还包括系统中的命令,和一些自己编写的函数,这些…

    2017-05-23
  • 马哥教育网络班第21期+第二周课程作业

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。 命令 选项 解释 cp -r 递归复制 copy -f 强行复制,若已存在则覆盖 -i 交互式 -p 保留属主属组权限时间戳 -L(不加也可以,默认) (源文件为链接)复制指向连接的文件 -P (源文件为链接) 以链接的方式复制过来 -a 归档复制,常用备份 命令 选项 …

    Linux干货 2016-07-17