linux中crontab和at

1、 Red Hat的发行版本中,通常还可以使用工具ntsysv设置服务的自启动状态。 #类似chkonfig 服务名 on|off

2、系统服务脚本目录:/etc/init.d


3、ps:

-a:显示所有终端进程;

-u:显示所有用户进程;

-x:显示所有进程,包括没有明确终端的进程;

-e:显示所有进程。与x类似,但是用BSD系统格式;

-f:显示UID,PPID(父进程ID)。。。;

-l:以长格式显示进程列表;

4、top:实时显示进程:

P:按CPU使用率由高到低排序;

M:按内存占用率排序;

h:查看帮助信息;

5、nice:查看默认进程优先级:(进程一般默认为0,一共四十个等级。-20到19)

-n:指定命令或者程序的优先级;

 

renice -n PID:改变进程优先级;

6、两个系统服务crond atd 

crontab 

备份以及恢复计划任务:

1 crontab -l > root_cron
2 
3 crontab -r
4 
5 crontab root_cron
6 
7 crontab -l

7、

root可以看wlh的计划任务:

crontab -u wlh -l

默认情况下,系统会把提交的计划任务放在目录/var/spool/cron

限制某个用户在 /etc/cron.deny 添加用户名

8、

系统计划任务:

用ls命令查看系统中的计划任务目录:

1 root@ubuntu:/home/dyx 15:26:16 46# ls -ld /etc/cron* | grep "^d"
2 drwxr-xr-x 2 root root 4096 Jul 21 18:56 /etc/cron.d
3 drwxr-xr-x 2 root root 4096 Jul 24 11:12 /etc/cron.daily
4 drwxr-xr-x 2 root root 4096 Aug 18  2012 /etc/cron.hourly
5 drwxr-xr-x 2 root root 4096 Aug 18  2012 /etc/cron.monthly
6 drwxr-xr-x 2 root root 4096 Jan 12  2013 /etc/cron.weekly

运行的这些文件在:

/etc/crontab:

#Centos中:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

#Ubuntu中:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
*5****cactiuser php5 /var/www/cacti/poller/php>/dev/null 2>&1

9、

at:一次性计划任务:

-f:指定一个文件作为任务脚本;

-m:完成任务之后给用户发送一个邮件;

-l:列出计划任务表

-d:删除指定的计划任务

1 root@ubuntu:/etc 15:55:34 58# at now +2 minute  #之后按enter
2 warning: commands will be executed using /bin/sh
3 at> date >> /home/dyx/date.txt
4 at> <EOT>                       #按Ctrl+D 结束输入
5 job 9 at Wed Jul 24 15:57:00 2013
1 root@ubuntu:/home/dyx/linux 16:14:52 65# at now +1 minute -f /home/dyx/linux/helloword.sh
2 warning: commands will be executed using /bin/sh
3 job 10 at Wed Jul 24 16:16:00 2013

放在目录:/var/spool/at

限制某个用户:/etc/at.deny 添加用户名字

10、

日志守护进程syslogd

配置文件:/etc/syslog.conf

原文地址:https://www.cnblogs.com/yi-meng/p/3211034.html