PHP read lock file created by a different Linux user? -


on linux server, have 2 linux users:

  • jim - maintains central framework repository other users use, including 3rd party open source libraries such jobby.
  • rob - uses framework maintained jim specific work.

jobby php cron management script creates lock file @ /tmp/xxxxx.lck each job / process that's been started.

before rob came in, jim used stuff including both central framework , specific work. therefore cron script run jim , lock file created , owned jim script reads lock file no problem.

however, when rob came in , took on specific work, cron script rob run rob calls jobby library owned jim. lock file created , owned jim. cron script rob can't read lock file created jim , keeps giving jobby error:

error: unable open file (file: /tmp/xxxx.lck).

basically, script (rob) calls script b (jim) creates /tmp/xxxx.lck (-rw-r--r-- 1 jim jim), there secure way make script (rob) able read /tmp/xxxx.lck?

but ain't permissions (-rw-r--r--) right since allows read file? that's odd.

then why jobby giving error?

update

it occurs me when i'm writing question should find out why jobby throwing error in first place. , found this:

public function acquirelock($lockfile) {     if (array_key_exists($lockfile, $this->lockhandles)) {         throw new exception("lock acquired (lockfile: $lockfile).");     }      if (!file_exists($lockfile) && !touch($lockfile)) {         throw new exception("unable create file (file: $lockfile).");     }      $fh = fopen($lockfile, "r+");     if ($fh === false) {         throw new exception("unable open file (file: $lockfile).");     }      $attempts = 5;     while ($attempts > 0) {         if (flock($fh, lock_ex | lock_nb)) {             $this->lockhandles[$lockfile] = $fh;             ftruncate($fh, 0);             fwrite($fh, getmypid());             return;         }         usleep(250);         --$attempts;     }      throw new infoexception("job still locked (lockfile: $lockfile)!"); } 

so asking both reading , writing permissions of lock file.

since lock file (-rw-r--r-- 1 jim jim) script of rob won't able write --- guess problem?

but why jobby creates file jim opens rob?

is there way can make both creates , opens file rob?

this awkward. seems /tmp/xxxx.lck created jim before rob came in.

so need delete file /tmp/xxxx.lck jim. when rob runs script, same lock file created rob , everything's right again.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -