Startscript: using $! to create pidfile - returning wrong pid (off by one) occasionally
1
vote
1
answer
918
views
We have 3 instances of redis running on a test server.
For some reason, our start script which starts redis can write the wrong pid to a file. Here is what it's doing:
su redis -c "redis-server /redis.conf & echo \$! > /var/run/redis_6379"
If I chain together
redis_6379 start && redis_6380 start && redis_6381
start
and then I stop them like that and start them like that, after 10 or 15 iterations I'll encounter a pid in the start file that is off by 1.
Does anyone know why that may occur?
Asked by JasonG
(405 rep)
Sep 18, 2013, 03:14 PM
Last activity: Jun 22, 2014, 11:31 PM
Last activity: Jun 22, 2014, 11:31 PM