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

相关推荐

  • 系统管理之Selinux详解

    SELinux: SELinux概念SELinux配置启用SELinux管理文件安全标签管理端口标签管理SELinux布尔值开关管理日志查看SELinux帮助 SELinux概述 SELinux: Secure Enhanced Linux, 是美国国家安全局「NSA=The National Se…

    Linux干货 2016-09-21
  • linux基础入门

    前言:一次写博客,还写的Linux的专业知识,好多都是参考着写的,经过一周的学习,从一开始有很多名词都不了解,也算是零基础吧,到现在经过反复琢磨还是了解不少了,万事开头难,只要你肯、你愿意下功夫,一定是能很好完成的! Linux基础入门 一、目录结构与文件 /    根目录 Bin  存放系统启动文件及其内核 Dev …

    Linux干货 2017-07-15
  • http请求过程

    1、浏览器根据访问的域名找到其IP地址。DNS查找过程如下: 1.浏览器缓存:浏览器会缓存DNS记录一段时间。 2.系统缓存:如果在浏览器缓存里没有找到需要的域名,浏览器会查系统缓存中的记录。 3.路由器缓存:如果系统缓存也没找到需要的域名,则会向路由器发送查询请求。 4.ISP DNS缓存:如果依然没找到需要的域名,则最后要查的就是ISP缓存DNS的服务器…

    Linux干货 2017-10-23
  • bash变量之位置参数变量

        什么是变量     变量是 bash 环境中非常重要的一个玩意儿,就是让某一个特定字串代表不固定的内容就是了,讲的更简单一点,我们可以“用一个简单的 "字眼" 来取代另一个比较复杂或者是容易变动的数据”。    &nbsp…

    Linux干货 2016-08-15
  • sed大法好

    sed sed概念 (1)基本概念:sed是流编辑器(stream editor),A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline).作用就是对输入的流(文件或者从一个管道输入的流…

    Linux干货 2016-12-02
  • 脚本练习

    脚本练习: 1、编写脚本/root/bin/systeminfo.sh,显示当前主机系统信息,包括主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小。 #!/bin/bash #功能:编写脚本/root/bin/systeminfo.sh,显示当前主机系统信息,包括主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,…

    Linux干货 2016-08-12