Macã§cronã®ä½¿ãæ¹ãå¦ã¶
æè¿ã¸ã§ã管çã®èªååããã¼ã¸ã§ã³ç®¡çããã£ã¨å°å
¥ãã¦å¿«é©ãªããã°ã©ãã³ã°çæ´»ãéããããããéããã°ãªããªãã¨æãã¦ãã¾ããããã§ã¸ã§ã管çã®èªååã®åå¼·ãå
¼ãã¦ã¿ã¼ããã«ã³ãã³ãã®cron
ã®åå¼·ããããã¨æãã¾ãã
åèå³æ¸ Software Design 2014å¹´12æå· | Hinemasã§å¦ã¶ã¸ã§ã管çè¶ å ¥é
Software Design (ã½ããã¦ã§ã¢ ãã¶ã¤ã³) 2014å¹´ 12æå· [éèª]
- åºç社/ã¡ã¼ã«ã¼: æè¡è©è«ç¤¾
- çºå£²æ¥: 2014/11/18
- ã¡ãã£ã¢: éèª
- ãã®ååãå«ãããã° (4件) ãè¦ã
Macã®åæè¨å®
crontabã使ã£ã¦cronã®è¨å®ãããã£ã¦ããã®ã§ããããã©ã«ãã®ã¨ãã£ã¿ã¼ã¯vimã¨ãªã£ã¦ãã¾ãã vimã®ããã¯ã¢ãããã¡ã¤ã«ãæªãããã¦cronãä¸æãåããªãã®ã§ä»¥ä¸ã®è¨å®ã.vimrcã«è¿½å ãã¾ãã
set backupskip=/tmp/*,/private/tmp/*
homebrewã§ã¤ã³ã¹ãã¼ã«ããmacvimã使ããããããã°ã¤ã³ã·ã§ã«ã®è¨å®ãã¡ã¤ã«ã«ä»¥ä¸ã®è¨å®ã追å ãã¾ãã
export EDITOR=/usr/local/bin/vim
ä¸è¬çãªRedhadã§ã®ãã£ã¬ã¯ããªæ§é ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãããããªã®ã§ã§ããã ãããããè¸è¥²ãã¾ãã
ãã¡ã¤ã«å/ãã£ã¬ã¯ããªå | å 容 |
---|---|
/etc/crontab | ã·ã¹ãã å ¨ä½ã«é¢ããcrontabãã¡ã¤ã« |
/var/spool/cron/user | ã¦ã¼ã¶åå¥ã®crontabãã¡ã¤ã«(crontabã³ãã³ãã§æå®ããæéãã¹ã¯ãªãããããã«è¨å®ããã) |
/etc/cron.hourly | æ¯æå®è¡ãããã·ã§ã«ã¹ã¯ãªãããé ç½®ãããã£ã¬ã¯ã㪠|
/etc/cron.daily | æ¯æ¥å®è¡ãããã·ã§ã«ã¹ã¯ãªãããé ç½®ãããã£ã¬ã¯ã㪠|
/etc/cron.weekly | æ¯é±å®è¡ãããã·ã§ã«ã¹ã¯ãªãããé ç½®ãããã£ã¬ã¯ã㪠|
/etc/cron.monthly | æ¯æå®è¡ãããã·ã§ã«ã¹ã¯ãªãããé ç½®ãããã£ã¬ã¯ã㪠|
/etc/cron.d | ä¸è¨ä»¥å¤ã«å®è¡ãããã·ã§ã«ã¹ã¯ãªãããé ç½®ãããã£ã¬ã¯ã㪠|
å®è¡æ¹æ³
ã³ãã³ã | å 容 |
---|---|
crontab -e | #è¨å®ãã¡ã¤ã«ç·¨é |
crontab -l | #è¨å®ãã¡ã¤ã«è¡¨ç¤º |
crontab -r | #è¨å®ãã¡ã¤ã«åé¤ |
#è¨å®ãã¡ã¤ã«ã®æ¸ãæ¹ å æ æ¥ æ ææ¥ ã³ãã³ã # ä¾1 æ¯æ¥3æéããã«job01.shãå®è¡ * */3 * * * job01.sh # ä¾2 æ~æ°´ææ¥ã®15:00ã¨17:00ã«job02.shãå®è¡ * 15,17 * * 1-3 job02.sh
è¨å®ãã¡ã¤ã«è©³ç´° | |
---|---|
å | 0~59ã¾ã§ã®æ°å |
æ | 0~23ã¾ã§ã®æ°å |
æ¥ | 1~31ã¾ã§ã®æ°å |
æ | 1~12ã¾ã§ã®æ°å |
ææ¥ | 0~7ã¾ã§ã®æ°å(0ã¨7=æ¥æ,1=ææ,...) |
ã³ãã³ã | ã¹ã¯ãªããorã³ãã³ã |
Timemachineã®ã¿ã¼ããã«ã³ãã³ãã§ã¿ã¤ã ãã·ã³HDDããã¦ã³ãããã¦ããå ´åã®ã¿æ¯æ¥24:00ã«ããã¯ã¢ãããè¡ãããã«è¨å®ãã¾ãã
ã¾ãtmutââil destinationinfo
ã³ãã³ããç¨ãã¦HDDã®IDãåå¾ãã¾ããããã¦tmutil startbackup --destination 調ã¹ãID
ã§ããã¯ã¢ãããéå§ãã¾ãã
# crontab -e 0 0 * * * /etc/cron.daily/backup.sh
#backup.sh #! /usr/local/bin/zsh if diskutil list | grep timemachine;then tmutil startbackup --destination FB2B288D-EA36-422C-96CA-0D9B0995706A else echo "I can't make backup file" > ./backup.log fi