Linuxのサービスと計画タスク

2482 ワード

サービス:
バックグラウンドで実行されるソフトウェアをサービスパラメータと呼びます:start stop restart
apache起動後デフォルト降格
service httpd start      /etc/init.d/httpd  shell  
 /etc/init.d       ,   /etc/rc.d/init.d
[wyb@localhost ~]$ ls -al /etc/init.d
lrwxrwxrwx. 1 root root 11 Apr 11 02:54 /etc/init.d -> rc.d/init.d

サービスの追加:
     /etc/init.d/   

自己起動するには、次の手順に従います.
chkconfig --list   //  chk       
chkconfig --add httpd      chk    
chkconfig --del httpd    httpd  chk  
chkcofnig --level 35 httpd on  init 345   
chkcofnig --level 345 httpd off
/etc/rc.d/rc3.d rc5.d   httpd

計画タスク:
起動方法:システム起動時にcronサービスを開くスクリプトがあり、起動後にcronコマンドはグローバルプロファイル/etc/crontabと/var/spool/cornディレクトリの下にあるユーザー名で命名されたファイルを検索します.
cron:目が覚めるたびに、現在実行するコマンドがあるかどうかを順番に確認します.最小単位は分です.
タスクの追加:
書式:分(0-59)時日月週(0-6)コマンド
     :
crontab -e  //             ,      

[wyb@localhost spool]$ crontab -e   //    ,      /var/spool/cron/username     
no crontab for wyb - using an empty one
*/1 * * * * date >> /tmp/date.txt   //      date.txt  
1 * * * * date >> /tmp/date1.txt        //           
~
~
~
"/tmp/crontab.T8sDqC" 1L, 34C written
crontab: installing new crontab
[wyb@localhost spool]$ sudo ls /var/spool/cron/
wyb
[wyb@localhost spool]$ sudo cat /var/spool/cron/wyb
*/1 * * * * date >> /tmp/date.txt
1 * * * * date >> /tmp/date1.txt
[wyb@localhost spool]$ 

     :
  /etc/crontab      //   root  ,      
vim /etc/crontab  root    ,     
01 * * * *        date >> /tmp/date2.txt            

ユーザー・タスクの表示:
[wyb@localhost tmp]$ sudo cat /var/spool/cron/wyb   //       
*/1 * * * * date >> /tmp/date.txt
[wyb@localhost tmp]$ sudo tail -5 /etc/crontab   //      
# |  |  |  .------- 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
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
*/1 * * * * wyb date >> /tmp/wyb.txt
[wyb@localhost tmp]$ crontab -l   //             
*/1 * * * * date >> /tmp/date.txt
[wyb@localhost tmp]$ crontab -r   //          ,            ,      /etc/crontab    
[wyb@localhost tmp]$ crontab -l
no crontab for wyb
[wyb@localhost tmp]$ sudo tail -3 /etc/crontab 
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
*/1 * * * * wyb date >> /tmp/wyb.txt
[wyb@localhost tmp]$