PID File for squid in Fedora – 21 (

So, the other day, I wanted to have squid store its pid in the regular ‘var/run’ directory. Good simple enough – just add the following to “/etc/squid/squid.conf” :

pid_filename /var/run/squid/

and create the /var/run/squid directory. Simple, hold on not so fast. Reboot and psssst.. ‘/var/run/squid’ is gone. Finally found that /var/run is handled by systemd-tmpfiles and thus you need to do this as well:

cat <>/lib/tmpfiles.d/squid.conf
d /run/squid 700 squid squid

So, basically you need to tell tmpfiles to create the squid directory as well.. How complicated things are becoming 🙂

Using file partially for filenames

There are some commands that take file name and there are some case where you need to give file name. But there are some cases where you want to modify the file before passing it to the command. What do you do in these case’s?

I had a file containing huge amount of data and for some testing I wanted to pass only the first few lines of the file and not the complete file.  And since the file only accepted filename and would not take any input from the STDIN so only option was to create a file with the required data in a temporary file. So, I sat back to figure out some way to do it and finally found I can use this:

testcommand -f<(head -1 )

The “testcommand” parameter “-f” requires a filename. And here we are passing the file to the command after filtering it with head command. You can use any bash command inside the <() combination.

Enhanced by Zemanta