best way to obtain a lock in php

I'm trying to update a variable in APC, and will be many processes trying to do that. APC doesn't provide locking functionality, so I'm considering using other mechanisms... what I've found so far...

What is the best way to ensure only one instance of a Bash script is running?

What is the simplest/best way to ensure only one instance of a given script is running - assuming it's Bash on Linux? At the moment I'm doing: ps -C script.name.sh > /dev/null 2>&1 ||...

How do I check the exit code of a command executed by flock?

Greetings all. I'm setting up a cron job to execute a bash script, and I'm worried that the next one may start before the previous one ends. A little googling reveals that a popular way to...

2D Spatial Data Structure suitable for Flocking Boids in Java

I'm working on a flocking boids simulation just for fun, and I want to optimise it a bit. The area that needs work is finding boids near a given boid. I figure that to do that some kind of spatial...

Atomically appending a line to a file and creating it if it doesn't exist

I'm trying to create a function (for purposes of logging) append($file, $data) that creates $file if it doesn't exist and atomically appends $data to it. It has to support high...

Mac OS X equivalent of Linux flock(1) command

Is there a flock command on Mac OS X that manages file lock? http://linux.die.net/man/1/flock

Creating a directory from multiple threads

If multiple threads do the following: if ( !is_dir($dir) ) mkdir($dir, 0, true); what will happen if two threads will detect "at the same time" that the directory does not exist and then...

"sqlite3.OperationalError: database or disk is full" on Lustre

I have this error in my application log: sqlite3.OperationalError: database or disk is full As plenty of disk space is available and my SQLite database does not appear to be corrupted...

Locking Linux Serial Port

I have an issue that I'm trying to solve regarding the serial port in Linux. I'm able to open, read from, and close the port just fine. However, I want to ensure that I am the only person...

Creating a SQL script for contact form in PHP and MySQL

I am very new to HTML, PHP, & MySQL. The below is for a homework project. We are extending a project that we did before. The project before we created a contact form with HTML and PHP, then...

flock permission denied bash

I have written a little test script to prevent running my script simultaneously with flock: #!/bin/bash scriptname=$(basename $0) lock="/var/run/${scriptname}" umask 0002 exec 200>$lock flock -n...

Using File#flock as ruby global lock (mutex for processes)

I am having concurrency issues between two processes after short research I have seen that temporary file is suggested solution to this problem. So solution would be to create /tmp/global.lock and...

Linux flock, how to "just" lock a file?

In Bash, I'm trying to make a function getLock to be used with different lock names. function getLock { getLock_FILE="${1}" getLock_OP="${2}" case "${getLock_OP}" in ...

python lockf and flock behaviour

I have read enough posts on stackoverflow regarding the difference between flock/lockf/fcntl but I am unable to answer the below observation: >>> import fcntl >>> a = open('/tmp/locktest',...

PHP flock() behaviour difference on Windows vs Linux

I am executing the same code snippet on a Windows machine and a Linux machine. Both are running PHP 5.4: $file = "lock.txt"; $fp = fopen($file, "w+"); flock($fp,...

How can you create a cross-thread cross-process lock in python?

https://pypi.python.org/pypi/lockfile/0.12.2 states: This package is deprecated. It is highly preferred that instead of using this code base that instead fasteners_ or oslo.concurrency is used...

"Conversion failed because the data value overflowed the specified type" error applies to only one column of the same table

I am trying to import data from database access file into SQL server. To do that, I have created SSIS package through SQL Server Import/Export wizard. All tables have passed validation when I...

Will converting to PySDL2 make my app run faster than it does under PyGame?

I've written a little toy in Python using Pygame. It generates critters (a circle with a directional line, not an image) to wander around the screen. I'm interested in making it more...

Does flock understand && command for multiple bash commands?

I am using bash and flock on centos. Normally I would run cd /to/my/dir && python3.6 runcommand.py But then we add it to cron and don't want output so add > /dev/null 2>&1 And add a flock before...

jest hangs indefinitely, runs no tests

Every time I run jest it never runs anything. I have let the counter go arbitrarily high. I have run jest with --no-cache jest --debug output is as follows: { "configs": [ { ...

RDO install OpenStack queens all-in-one get stuck

When I use packstack to install openstack queens allinone, it got stuck at: # sudo packstack --answer-file pack-1534411186.txt Welcome to the Packstack setup utility The installation log file is...

Warning: flock() expects parameter 1 to be resource, string given

I have this very simple program in PHP that does not want to work. It returns the same error as topic for unknown reasons to me. $file = 'counter.txt'; $counter =...

Check if file is locked by concurrent process

I have a process that writes a file using file_put_contents(): file_put_contents ( $file, $data, LOCK_EX ); I have added the LOCK_EX parameter to prevent concurrent processes from writing to the...

How to force restart pod when there is change in container environment variable

i am trying to deploy image which has some change to it environment variables, but when i do so i am getting below error The Pod "envar-demo" is invalid: spec: Forbidden: pod updates may...

AddInstanceForFactory & HALC_ShellDriverPlugIn errors when using SDL2 with Xcode?

I am trying to make a simple game using SDL2 and C++ on Xcode 11.2.1; however, my progress has been stopped by an error. All it takes to encounter these errors is simply initializing SDL. Just...

Trying to add Zsh shell (with Oh My Zsh!) to new Windows Terminal, what's the right way?

Using MSYS2 and following Zsh on Windows via MSYS2 guide I installed Zsh shell on my Windows 10 Pro workstation. I installed Oh My Zsh! too via curl and powerlevel10k theme. Now I'd like to use...

Permission denied creating /go directory in Jenkins when building a project that uses go modules

When I try to build a go Jenkins project that uses go modules, I see this error: go: writing go.mod cache: mkdir /go: permission denied I also see a similar error for every...

How can I fix an Opencart 3 page loading error?

The following problem sometimes occurs when the page loads and also on the admin page. The error is not permanent and will disappear after the page is refreshed. What could be the problem and how...

Xcode log message "flock failed to lock list file"

I am getting this message logged when running a freshly created macOS app in Xcode (Apple Silicon / Xcode 12). flock failed to lock list file...

fclose(): Argument #1 ($stream) must be of type resource, bool given

I just restart my laravel 8.0 project and I got this below error, please what could be wrong, this happens anytime I run "PHP artisan serve" TypeError fclose(): Argument #1 ($stream) must be...