ÔõÑùÔÚLinuxÉÏÉèÖÃϵͳ׼ʱʹÃü
ÔõÑùÔÚlinuxÉÏÉèÖÃϵͳ׼ʱʹÃü
ÔÚLinuxϵͳÖУ¬ÎÒÃǾ³£ÐèҪ׼ʱִÐÐһЩʹÃü£¬ºÃ±È±¸·ÝÊý¾Ý¿â¡¢ÕûÀíÈÕÖ¾ÎļþµÈµÈ¡£ÎªÁËʵÏÖÕâЩ׼ʱʹÃü£¬ÎÒÃÇ¿ÉÒÔʹÓÃLinuxϵͳµÄ׼ʱʹÃü¹¤¾ß¡ª¡ªcrontab¡£
Ò»¡¢Ïàʶcrontab
crontabÊÇLinuxϵͳϵÄÒ»¸ö׼ʱʹÃüÖÎÀí¹¤¾ß£¬ÓÃÓÚÖ´Ðа´ÆÚµÄʹÃü¡£Ëü»áƾ֤Ԥ¶¨µÄʱ¼äÖ´ÐÐÖ¸¶¨µÄʹÃü£¬¿ÉÒÔÔÚºǫ́×Ô¶¯ÔËÐУ¬ºÜÊÇÀû±ã¡£
¶þ¡¢ÉèÖÃ׼ʱʹÃü
·¿ªÖնˣ¬ÊäÈëÏÂÁîcrontab -e£¬½øÈë׼ʱʹÃü±à¼Æ÷¡£
ÔÚ±à¼Æ÷ÀÎÒÃÇ¿ÉÒÔÉèÖÃеÄ׼ʱʹÃü¡£Ã¿Ò»Ðдú±íÒ»¸öʹÃü£¬Ã¿ÐеÄÃûÌÃÈçÏ£º
·ÖÖÓ Ð¡Ê± ÈÕÆÚ ÔÂ·Ý ÐÇÆÚ ÒªÖ´ÐеÄÏÂÁî
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬·ÖÖÓÈ¡Öµ¹æÄ£ÊÇ0-59£¬Ð¡Ê±È¡Öµ¹æÄ£ÊÇ0-23£¬ÈÕÆÚÈ¡Öµ¹æÄ£ÊÇ1-31£¬Ô·ÝÈ¡Öµ¹æÄ£ÊÇ1-12£¬ÐÇÆÚÈ¡Öµ¹æÄ£ÊÇ0-7£¨0ºÍ7¶¼ÌåÏÖÐÇÆÚÈÕ£©¡£
ÀýÈ磬ÏÂÃæµÄʾÀýÊÇÌìÌìÏÂÖç3µã׼ʱ±¸·ÝÊý¾Ý¿â£º
0 15 * * * /usr/bin/mysqldump -u username -p password database > /path/to/backup.sql
µÇ¼ºó¸´ÖÆ
Õâ¸öʾÀýÖУ¬0 15 * * *ÌåÏÖÌìÌìµÄµÚ15Сʱ£¨¼´ÏÂÖç3µã£©£¬/usr/bin/mysqldump -u username -p password database > /path/to/backup.sqlÊÇÒªÖ´ÐеÄÏÂÁ½«Êý¾Ý¿â±¸·Ýµ½/path/to/backup.sqlÎļþÖС£
±à¼Íê±Ïºó£¬°´ÏÂCtrl + X£¬È»ºó°´ÏÂYÉúÑÄÍ˳ö¡£
Èý¡¢³£ÓõÄcrontab²Ù×÷ÏÂÁî
ÔÚʹÓÃcrontabʱ£¬»¹¿ÉÒÔʹÓÃһЩÏÂÁîÀ´ÖÎÀí׼ʱʹÃü¡£
crontab -l£ºÁгöÄ¿½ñÓû§µÄ׼ʱʹÃüÁÐ±í¡£
crontab -e£º±à¼Ä¿½ñÓû§µÄ׼ʱʹÃüÁÐ±í¡£
crontab -r£ºÉ¾³ýÄ¿½ñÓû§µÄ׼ʱʹÃüÁÐ±í¡£
crontab -u username -l£ºÁгöÖ¸¶¨Óû§µÄ׼ʱʹÃüÁÐ±í¡£
crontab -u username -e£º±à¼Ö¸¶¨Óû§µÄ׼ʱʹÃüÁÐ±í¡£
crontab -u username -r£ºÉ¾³ýÖ¸¶¨Óû§µÄ׼ʱʹÃüÁÐ±í¡£
ËÄ¡¢ÆäËû×¢ÖØÊÂÏî
ÔÚ±àд׼ʱʹÃüʱ£¬Òª×¢ÖØÏÂÁîµÄÖ´Ðз¾¶¡£×îºÃʹÓþø¶Ô·¾¶£¬×èÖ¹ÓÉÓÚÇéÐαäÁ¿µÈÎÊÌâµ¼ÖÂÕÒ²»µ½ÏÂÁî¡£
ÔÚ׼ʱʹÃüÖУ¬¿ÉÒÔʹÓÃͨÅä·ûÀ´ÊµÏÖ¸üÎÞаµÄʹÃüµ÷Àí¡£ºÃ±È£¬*ÌåÏÖËùÓпÉÄܵÄÈ¡Öµ£¬*/nÌåÏÖÿn¸öʱ¼äµ¥Î»¡£
crontabÖ§³ÖʹÓÃ@rebootÒªº¦×ÖÀ´ÊµÏÖϵͳÆô¶¯Ê±×Ô¶¯Ö´ÐеÄʹÃü¡£ÀýÈ磺
@reboot /path/to/your/script
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇÔÚLinuxÉÏÉèÖÃϵͳ׼ʱʹÃüµÄÒªÁìºÍʾÀý¡£Í¨¹ýºÏÀíÉèÖÃ׼ʱʹÃü£¬ÎÒÃÇ¿ÉÒÔʵÏÖ×Ô¶¯»¯ÔËά²Ù×÷£¬Ìá¸ßЧÂʺÍÎȹÌÐÔ¡£Ï£Íû¶ÔÄãÓÐËù×ÊÖú£¡
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖÃϵͳ׼ʱʹÃüµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡