cron을 이용하여 php 자동실행
페이지 정보
작성자 서방님 댓글 0건 조회 122회 작성일 11-06-02 13:37본문
1. cron 설정
[root@linux]# crontab -l
//현재 cron 확인
[root@linux]# crontab -e
//cron 편집 - vi 와 사용법 같음
(예)
[root@SRV182 ~]# crontab -l
30 04 10 * * /root/cron/account_month.php
//매월 10일 04시 30분에 /root/cron/account_month.php를 실행하라
(필드 설정)
|
분 시 날짜 달 요일 권한 command 형식으로 입력해줌...
ex) 05 * * * * root /home/html/update.php -> 매시 5분에 update.php문 실행
ex) 05 15 * * * root /home/html/update.php -> 매일 오후 3시 5분에 update.php문 실행
2. php 파일 설정
#!/usr/bin/php -q (이건 리눅스에서 whereis php 해서 나오는 경로를 적어준다.)
<?
$conn=mysql_connect("localhost","user","password");
mysql_select_db("edumeca",$conn);
mysql_query("update tablename set updatefield=updatefield+1");
?>
[root@linux]# chmod +x /root/cron/account_month.php
//실행권한을 준다
(실행 되었는지 로그 확인)
[root@linux]# vi /var/log/cron
댓글목록
등록된 댓글이 없습니다.