JiYoung Dev πŸ–₯

[Linux] cron (2023.08.11) λ³Έλ¬Έ

full stack/Linux

[Linux] cron (2023.08.11)

Shinjio 2023. 8. 11. 12:42

cron 

 

λ‚΄κ°€ μ›ν•˜λŠ” μ‹œκ°„λŒ€μ— μž‘μ—…μ„ 진행할 수 μžˆλ„λ‘ μ„€μ • 

→ 배치 μ²˜λ¦¬μ‹œ μ‚¬μš© (λ°±μ—…) 

 

λΆ„, μ‹œ, 일, μ›”, μš”μΌμˆœ

 

 

 

정해진 μ‹œκ°„μ΄ 되면 λ°±μ—…λ˜λ„λ‘ cron μ„€μ •ν•˜κΈ°

 

 

 

[root@localhost backup]# nano /etc/crontab
[root@localhost backup]# systemctl restart crond
[root@localhost backup]# systemctl status crond

 

 

1. 배치 ν”„λ‘œκ·Έλž¨ μ½”λ“œ - backup.sh (본인 κ³„μ •μ—μ„œ 생성)

home 디렉토리λ₯Ό λ°±μ—… ν›„ μ••μΆ• → backup 폴더에 μ €μž₯ν•˜λŠ” ν”„λ‘œκ·Έλž¨

 

 

 

backup 폴더 생성  : mkdir /backup

backup.sh μ‹€ν–‰κΆŒν•œ λΆ€μ—¬ : chmod 755 backup.sh

 

 

2. crontabl ν”„λ‘œκ·Έλž¨ μ½”λ“œ

 

30뢄에 backup을 μ‹€ν–‰ν•˜κ² λ‹€! 

 


nano μ‚¬μš©ν•˜μ—¬ μˆ˜μ •ν•  것 

 

3. crontab μ„€μ • ν›„ μ‹œμŠ€ν…œ μž¬μ‹œμž‘

# systemctl restart crond

 

- systemctl : ν”„λ‘œκ·Έλž¨ μ‹€ν–‰μ‹œν‚€λŠ” λͺ…λ Ήμ–΄ (start, stop, restart, status)

 

# systemctl restart crond

 

 

μ‹€ν–‰ κ²°κ³Ό