PHP crontab 보여주기

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] => sudo: no tty present and no askpass program specified
# )

3 같이 보기

4 참고 자료

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