任务计划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
下一篇 2017-05-15

相关推荐

  • 密码保护:第二天

    无法提供摘要。这是一篇受保护的文章。

    Linux干货 2017-07-15
  • 给linux系统添加新的磁盘

    虚拟化环境中,我们经常会遇到需要增加磁盘容量的情况,通常有两种方式,第一种是添加一块新的硬盘,另一种是扩容原有磁盘,以下是添加新磁盘至linux系统的操作规范。注:具体磁盘信息可能有所不同。 ##查看新增加磁盘/dev/sdb的信息 [root@CentOS7 ~]# fdisk -l /dev/sdb   Disk /dev/sdb: 5368 …

    Linux干货 2016-11-11
  • 为什么中国的网页设计那么烂?

    Nick Johnson,一个有12年经验的Web设计师在它的blog里写下了“Why is Chinese Web Design So Bad”,新浪,人人,百度,阿里巴巴,腾讯榜上有名。其中的观点相当的好,希望所有的中国人都读一下。我不全文翻译了,只是给大家看一些摘要。(保证不会像《环球时报》一样) —————————— 作者2005年的夏天来到中国,他…

    Linux干货 2016-07-11
  • 设计模式(七)组合模式Composite(结构型)

    1. 概述 在数据结构里面,树结构是很重要,我们可以把树的结构应用到设计模式里面。 例子1:就是多级树形菜单。 例子2:文件和文件夹目录 2.问题 我们可以使用简单的对象组合成复杂的对象,而这个复杂对象有可以组合成更大的对象。我们可以把简单这些对象定义成类,然后定义一些容器类来存储这些简单对象。客户端代码必须区别对象简单对象和容器对象,而实际上大多数情况下用…

    Linux干货 2015-07-01
  • 用shell脚本打等腰三角新

       *   ***  ***** *******   预览图形 发现图形由三个变量组成 行数n 每行的空格数a 和每行的符号数b 关系是    a=n-当前行数    b=2xn-1   并且空格都在符号前 根据关系编写脚本 #!/bin/bash read…

    Linux干货 2016-08-22
  • tom猫—–(Tomcat详解)

    目录 安装tomcat tomcat目录结构及配置文件构成以及主配置文件server.xml ,tomcat中的组件 实现反代tomcat的方法 nginx+tomcat cluster http(mod_porxy_http)+tomcat cluster http(mod_porxy_ajp)+tomcat cluster http(mod_jk)+to…

    2017-11-16