Not sure if this is server related or normal behavior, but I thought I’d ask. I run a relatively high-traffic website (200k+ uniques/week) and we serve lots of links through a PHP file containing redirects.
The only problem is, I need to update this file frequently, which I do via SFTP. The file is around 800k in size and takes a second or so to download. However, users have informed me that sometimes the links redirected through the PHP file don’t work, and I’ve realized that this only happens when I’m uploading or downloading the file via SFTP.
So my question is: Is there any way I can keep the file executable for users while I upload new copies of it via FTP? This downtime is bothersome for my users. Is this some setting in Linux that I’m not aware of, or is there nothing I can do about this? If it makes a difference, my server is running Centos.
Upload it as a different filename, and then rename it to clobber the old one. The upload takes significant time (if anything beyond ‘instantaneous’ is significant). rename (or mv) is atomic and won’t make your users wait. You could take as much time as you need uploading the file, and then in a split second rename it.