|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-06-23 19:42 UTC] sjoerd-php at linuxonly dot nl
[2009-07-29 23:44 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 18:00:02 2025 UTC |
Description: ------------ Trying to install crontab with PHP cli, system (and passthru) function returned error-code of "1" with output "no crontab for USER" (USER should be replaced with real system user to whom crontab should be installed). the code is: $ php -r '$c="crontab -u USER -l";system($c,$status); printf("%s (%d)\n",$c,$status);' the output is: no crontab for USER crontab -u USER -l (1) Since no crontab is been installed for the USER, the output was expected, but I don't think error code should be 1 for this. For comparison, python and c++ both returns 256 of error code for this error ("no crontab for USER be installed"). According to an error code definition of unix system (in ubuntu, /usr/include/asm-generic/errno-base.h and errno.h), 1 be translated as "permission denied". Followings are comparison code and result for other languages. They returned error number 256 but PHP. * c++ #include <iostream> #include <cstdlib> using namespace std; int main(int argc,char *argv[]){ string cmnd("crontab -u USER -l"); int errcode=system(cmnd.data()); printf( "%s (%d)\n", cmnd.data(), errcode ); return 0; } root@server2:~/diary# ./a.out no crontab for USER crontab -u USER -l (256) * python root@server2:~/diary# python -c 'import os; c="crontab -u USER -l"; print "%s (%d)" % (c, os.system(c))' no crontab for USER crontab -u USER -l (256) * php root@server2:~/diary# php -r '$c="crontab -u USER -l";system($c,$status); printf("%s (%d)\n",$c,$status);' no crontab for USER crontab -u USER -l (1) * error number refference root@server2:~/diary# awk '/[\x20\t]+1[\x20\t]+/' /usr/include/asm-generic/errno-base.h #define EPERM 1 // Operation not permitted Reproduce code: --------------- # make sure there's NO crontab installed for USER. $ php -r '$c="crontab -u USER -l";system($c,$status); printf("%s (%d)\n",$c,$status);' Expected result: ---------------- Output: no crontab for USER crontab -u USER -l (256) Actual result: -------------- Output: no crontab for USER crontab -u USER -l (1)