"PHP crontab 보여주기"의 두 판 사이의 차이

41번째 줄: 41번째 줄:
[root@jmnote ~]# vi /etc/sudoers
[root@jmnote ~]# vi /etc/sudoers
</source>
</source>
<source lang='text' highlight='2'>
<source lang='text' highlight='2,5'>
Defaults    requiretty
Defaults    requiretty
Defaults:apache !requiretty
Defaults:apache !requiretty

2015년 2월 9일 (월) 14:34 판

아파치 PHP crontab 보여주기

1 방법 1: apache 계정의 크론탭

<?php
exec('crontab -l 2>&1', $output);
echo '<xmp>';
print_r( $output );
echo '</xmp>';
# Array
# (
#     [0] => no crontab for apache
# )

2 방법 2: root 계정의 크론탭

<?php
exec('crontab -l -uroot 2>&1', $output);
echo '<xmp>';
print_r( $output );
echo '</xmp>';
# Array
# (
#     [0] => must be privileged to use -u
# )
<?php
exec('sudo crontab -l -uroot 2>&1', $output);
echo '<xmp>';
print_r( $output );
echo '</xmp>';
# Array
# (
#     [0] => sudo: sorry, you must have a tty to run sudo
# )
[root@jmnote ~]# vi /etc/sudoers
Defaults    requiretty
Defaults:apache !requiretty
... (생략)
root	ALL=(ALL) 	ALL
apache	ALL=NOPASSWD:/usr/bin/crontab
<?php
exec('sudo crontab -l -uroot 2>&1', $output);
echo '<xmp>';
print_r( $output );
echo '</xmp>';
# Array
# (
#     [0] => 0 12 * * * php /var/www/batch/my_batch.php
#     [1] => 35 * * * * python /root/pywikipedia/redirect.py double -always
#     [2] => 
# )

3 같이 보기

4 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}