1

We have a script (generator) that is creating a series of at jobs. The at jobs fire another PHP script. The generator script loops through and does something like this:

exec('/usr/bin/at 5:00 May 11, 2015 -f ' . $filename); 

$filename looks something like this:

php /some-location/some-script.php arg1 arg2 arg3 

It's working awesome, we love it. What I'm trying to figure out is how to grab the job id and the file name in /var/spool/at/filename from the generator script as it runs so I can store it in case we need to alter/cancel after they been scheduled.

Does anyone have any idea how I can grab that info from the exec() that's creating the at Job?

1 Answer 1

2

According to the documentation on PHP exec():

If the output argument is present, then the specified array will be filled with every line of output from the command.

Does your version of at declare the job number?

$ echo /bin/true | at now + 1hour job 1 at Fri Apr 24 12:00:00 2015 

If so, you might then use explode() with a space delimiter to get the job number.

<?php // Remember to redirect stderr to stdout with "2>&1" $command = "echo /bin/true | at now + 1hour 2>&1"; $at_message = explode(" ", exec($command, $output, $return_value)); $job_number = $at_message[1]; echo $job_number; ?> 
1
  • it does not use a job number - i really need the filename in var/spool/at. thanks for the info on exec though, i'm sure that'll come in useful Commented Apr 28, 2015 at 12:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.