任务计划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文件系统概论

    Linux之我见     在2016农历丙申年2016年猴年,对于小白的我来说接触到了江湖流传的武功秘籍之-Linux心法,第一次接触到命令行,知道在键盘上随便敲击命令就可以满屏跑数据,就像看过的美国大片里黑客帝国里面的画面,感觉学会好后可以装逼了,废话不多说了,允许在下斗胆介绍Linux文件系统。     &nbsp…

    Linux干货 2016-03-24
  • dns配置

    dns

    Linux干货 2018-01-22
  • Linux哲学思想

    一、一切皆文件     1、将所有资源都抽象成文件形式;     2、几乎可以通过读写文件的形式,操作所有的系统资源。 二、由一个一个的小程序组成,且每一个小程序只做一件事情,并且只做好该件事情即可     1、一个小程序只做好一件事情,即…

    Linux干货 2016-09-19
  • linux文件权限

    一、前言 在linux中,每个目录或者文件都有相对应的权限,linux通过文件属主(user),文件属组(group),其它人(order)对一个文件或者目录控制读写执行权限,当然在这些基本权限之外还有特殊权限,facl(file access control list)等。 二、文件基本权限    2.1:属主、属组、order概念 &…

    Linux干货 2015-08-17
  • 用户及权限管理

    新建用户用到的相关文件/etc/default/useradd /etc/login.defs /etc/skel/* 批量创建用户1.创建用户列表user.txt(文件格式同/etc/passwd) 2.newusers user.txt 3.创建密码文件passwd.txt(格式  用户名:密码) 4.cat passwd.txt | chpa…

    Linux干货 2016-08-11
  • 用户和组相关的配置文件总结

    前言: 在用户管理,组管理过程中,最基本的四个文件就是/etc下面的passwd,shadow,group,gshadow。他们记录了与用户和组相关的信息。是学习和深入了解用户,组的基本。 除了这些基本的配置文件 还有与初始化相关的配置文件。定义用户添加时初始状态的配置文件/etc/default/useradd。 以及用户家目录的内容文件参考目录/etc/…

    Linux干货 2016-10-24