2023년 신상 호텔 리스트
최근에 오픈한 호텔을 찾는다면 살펴보세요

Ubuntu - 우분투 cron job 크론잡 설정

조회수: 502

서버에 접속 후

crontab -e 실행하자.

처음 실행하면 목록이 나올 것이다. 

가장 쉬운 걸로 선택하면 된다.

 

아래와 같이 설명이 되어 있다.

 

 

# Edit this file to introduce tasks to be run by cron.

# 

# Each task to run has to be defined through a single line

# indicating with different fields when the task will be run

# and what command to run for the task

# 

# To define the time you can provide concrete values for

# minute (m), hour (h), day of month (dom), month (mon),

# and day of week (dow) or use '*' in these fields (for 'any').

# 

# Notice that tasks will be started based on the cron's system

# daemon's notion of time and timezones.

# 

# Output of the crontab jobs (including errors) is sent through

# email to the user the crontab file belongs to (unless redirected).

# 

# For example, you can run a backup of all your user accounts

# at 5 a.m every week with:

# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/

# 

# For more information see the manual pages of crontab(5) and cron(8)

# 

# m h  dom mon dow   command

 

command를 넣어야 한다.

예를 들어서 라라벨의 경우에는

* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1

이렇게 넣으면 작동한다.

 

별표 5개(***** )는 매 분이라는 의미다.

https://crontab.guru/에 접속하면 감이 올 것이다. 

처음에는 머리 아프다. 계속 반복 연습.