I am writing a c program that will call a php script every few seconds in the background. So when you first call this program, it will create a child process through fork, and then exit the parent process, while the child process will be in an infinite loop. So far inside that infinte loop, I have the line system("echo hello >> daemon.txt")
inside hte while loop, and it updates accordingly, so I know that the process is working. However when I call my script, it seems like it does not execute.
My php script timeChecker.php
#!/usr/bin/php
<?php
$handle =fopen("hello","a");
fwrite($handle, "boo
");
fclose($handle);
?>
When called from commandline using either php timeChecker.php or ./timeChecker.php, the code executes as it should.
However, after trying multiple methods of calling the command such as system("php timeChecker.php")
, system("/usr/bin/php timeChecker.php")
, system("/usr/bin/php var/www/timeChecker.php")
, system("/var/www/timeChecker.php")
and all variations of that, the code still does not execute. Is there something simple that I am doing wrong? Or should I simply use a different method of checking the script?