Jump to content

I can't add an at command from php. Please help.


Go to solution Solved by SLSCoder,

Recommended Posts

Ubuntu 20.04 apache2 php 8.0.14 php-fpm

I'm trying to execute an at command from php.
The code is:

$out = shell_exec('echo mkdir /var/www/test | at now +1 minutes');
echo $out . "<br>";

If I run that command from the command line it works fine.

When I run it from php I get nothing back into the $out variable and no directory is created.

How can I run an at command from php?

A couple of notes/suggestions for you:

First, shell_exec is equivalent to using backtics, inherited from the bourne bash shell.

$out = `echo mkdir /var/www/test | at now +1 minutes`;

I can see you have a contrived example, but if you actually want to depend on os return codes from the command you have to use exec, as it allows for the passing of an optional return code parameter, which in many cases is probably a preferable way to determine whether your commands ran successfully or had errors.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.