ºìÁªLinuxÃÅ»§
Linux°ïÖú

LinuxϵͳÖÐÉèÖÿª»ú×Ô¶¯ÔËÐеÄÁ½ÖÖ·½·¨

·¢²¼Ê±¼ä:2017-12-17 11:14:55À´Ô´:ºìÁª×÷Õß:Ronny
ÓÐʱ¿ÉÄÜ»áÐèÒªÔÚÖØÆôʱ»òÕßÿ´ÎϵͳÆô¶¯Ê±ÔËÐÐijЩÃüÁî»òÕ߽ű¾¡£ÎÒÃÇÒªÔõÑù×öÄØ£¿±¾ÎÄÖÐÎÒÃǾͶԴ˽øÐÐÌÖÂÛ¡£ ÎÒÃÇ»áÓÃÁ½ÖÖ·½·¨À´ÃèÊöÈçºÎÔÚ CentOS/RHEL ÒÔ¼° Ubuntu ϵͳÉÏ×öµ½ÖØÆô»òÕßϵͳÆô¶¯Ê±Ö´ÐÐÃüÁîºÍ½Å±¾¡£ Á½ÖÖ·½·¨¶¼Í¨¹ýÁ˲âÊÔ¡£

LinuxϵͳÖÐÉèÖÿª»ú×Ô¶¯ÔËÐеÄÁ½ÖÖ·½·¨LinuxϵͳÖÐÉèÖÿª»ú×Ô¶¯ÔËÐеÄÁ½ÖÖ·½·¨

·½·¨ 1 - ʹÓà rc.local
ÕâÖÖ·½·¨»áÀûÓà /etc/ ÖÐµÄ rc.local ÎļþÀ´ÔÚÆô¶¯Ê±Ö´Ðнű¾ÓëÃüÁî¡£ÎÒÃÇÔÚÎļþÖмÓÉÏÒ»ÐÐÀ´Ö´Ðнű¾£¬ÕâÑùÿ´ÎÆô¶¯ÏµÍ³Ê±£¬¶¼»áÖ´Ðиýű¾¡£

²»¹ýÎÒÃÇÊ×ÏÈÐèҪΪ /etc/rc.local Ìí¼ÓÖ´ÐÐȨÏÞ£¬

$ sudo chmod +x /etc/rc.local
È»ºó½«ÒªÖ´ÐеĽű¾¼ÓÈëÆäÖУº

$ sudo vi /etc/rc.local
ÔÚÎļþ×îºó¼ÓÉÏ£º

sh /root/script.sh &
È»ºó±£´æÎļþ²¢Í˳ö¡£Ê¹Óà rc.local ÎļþÀ´Ö´ÐÐÃüÁîÒ²ÊÇÒ»ÑùµÄ£¬µ«ÊÇÒ»¶¨Òª¼ÇµÃÌîдÃüÁîµÄÍêÕû·¾¶¡£ ÏëÖªµÀÃüÁîµÄÍêÕû·¾¶¿ÉÒÔÔËÐУº

$ which command
±ÈÈ磺

$ which shutter
/usr/bin/shutter
Èç¹ûÊÇ CentOS£¬ÎÒÃÇÐ޸ĵÄÊÇÎļþ /etc/rc.d/rc.local ¶ø²»ÊÇ /etc/rc.local¡£ ²»¹ýÎÒÃÇÒ²ÐèÒªÏÈΪ¸ÃÎļþÌí¼Ó¿ÉÖ´ÐÐȨÏÞ¡£

×¢Òâ:- Æô¶¯Ê±Ö´ÐеĽű¾£¬ÇëÒ»¶¨±£Ö¤ÊÇÒÔ exit 0 ½áβµÄ¡£

·½·¨ 2 - ʹÓà Crontab
¸Ã·½·¨×î¼òµ¥ÁË¡£ÎÒÃÇ´´½¨Ò»¸ö cron ÈÎÎñ£¬Õâ¸öÈÎÎñÔÚϵͳÆô¶¯ºóµÈ´ý 90 Ã룬ȻºóÖ´ÐÐÃüÁîºÍ½Å±¾¡£

Òª´´½¨ cron ÈÎÎñ£¬´ò¿ªÖն˲¢Ö´ÐÐ

$ crontab -e
È»ºóÊäÈëÏÂÐÐÄÚÈÝ£¬

@reboot ( sleep 90 ; sh \location\script.sh )
ÕâÀï \location\script.sh ¾ÍÊÇ´ýÖ´Ðнű¾µÄµØÖ·¡£


Ô­ÎÄÀ´×Ô£ºhttp://www.linuxprobe.com/automatic-running-methods.html
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 1 ÌõÆÀÂÛ

  1. Ronny ÓÚ 2017-12-17 11:15:06·¢±í:

    LinuxϵͳÖÐÉèÖÿª»ú×Ô¶¯ÔËÐеÄÁ½ÖÖ·½·¨