I need to run unix at command using PHP. How is it possible to do it? curl is not an option for what I am doing. If I try to run it simply exec('at') it gives no response. Though, if I run it using ssh, it works fine. So I guess this is permissions/path problem.
Remember that "at" receives its script from stdin, so you'll want to open a pipe to the at command using popen(). Write your commands to that pipe and close it. The time that you want "at" to run the command should be part of the command line when you open the pipe.
<?php
$r = popen('/usr/bin/at noon');
fwrite($r,"ls -l");
pclose($r);
?>
I suppose you have some real at command line because only at is invalid syntax. Your command should include some arguments.
However maybe your problem is that at is not in $PATH. Try to run at with the full path which is typically /usr/bin/at. Check this with whereis at.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With