I'm trying to run only one instance of a program, this is my runner script which is called from crontab:
#!/bin/bash
exec 9>./lockfile
if ! flock -n 9 ; then
echo "another instance of $0 is running";
exit 1
fi
node $(dirname $0)/init.js
The line in crontab is as follows:
*/5 * * * * /bin/bash /path/to/proyect/runner.sh >> /path/to/proyect/logs/output.log 2>> /path/to/proyect/logs/error.log
The weird thing is that after I kill the process the file stays locked