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
<?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
# )
[root@jmnote ~]# grep apache /etc/passwd
apache:x:48:48:Apache:/var/www:/sbin/nologin
[root@jmnote ~]# sed -i 's/\/sbin\/nologin/\/bin\/bash/g' /etc/passwd
[root@jmnote ~]# grep apache /etc/passwd
apache:x:48:48:Apache:/var/www:/bin/bash

3 같이 보기

4 참고 자료

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