1

I have a mac that is running MAMP and on a web page I am trying to run the exec() php command below.

$output = array();
$result_code = 0;
$command = "echo /Applications/MAMP/bin/php/php7.4.21/bin/php -q " . DOCUMENT_ROOT . "/custom/massimport/scripts/massimport.php param1 param2 | at now 2>&1";

exec($command, $output, $result_code);

When I try to run this command, I get...

at: cannot open lockfile /usr/lib/cron/jobs/.lockfile: Operation not permitted

I added at, crontab, php, httpd all to the "Full Disk Access" of mac. I tried chaging the user permissions and owner and group on the lock file. But I cannot seem to get it to work.

Any ideas?

Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
karozans
  • 53
  • 7
  • The MAMP user probably doesn't have access to the lock file, which is probably system generated. Do you really need to run it through cron, or can you have it run in the background with `&`? – aynber Jun 21 '22 at 19:45
  • The lock file is system generated, so I changed the perms and the owner/group, but that didn't seem to change anything. I am reading an argument now that says not to run it in the background because when the parent process stops it will terminate the child process as well, unless you jump through a bunch of other hoops to make it work. – karozans Jun 21 '22 at 20:05
  • I just found this. Maybe this is the issue with Mac. "In OS X, you can run a background job on a timed schedule in two ways: launchd jobs and cron jobs. (Older approaches, such as at jobs and periodic jobs are deprecated and should not be used.) This section explains these methods briefly and provides links to manual pages that provide additional details" – karozans Jun 21 '22 at 20:09
  • If I run at commands from the terminal, it seems to work just fine. – karozans Jun 21 '22 at 20:21

0 Answers0