https://itsfoss.com/open-source-impact-on-science/
Author: Helge
Find all ServerNames and ServerAliases in several vhosts.conf files
In Apache one specify the servername and serveralias in a virtualhost directive in possible a single .conf file.
We had an Apache webserver with hundreds of such .conf files. With this bash one-liner you can find all ServerName and ServerAlias’s:
cd /etc/httpd/vhosts.d/ ; find . -type f | xargs egrep -i 'servername|serveralias' | awk {'print $3'} | sort | uniq
Use a variable counter in a bash one-liner
I had 70 different domain names that I need to add in a ssl cnf file for creating a certificate request.
The 70 different domain names was in a text file, one per line:
domainname1.something.com
domainname2.somehing.com
...
In order to create the alternative names list, I used this bash oneliner:
teller=1; for i in `cat /tmp/disse2`; do echo "DNS.$teller = $i"; teller=$((teller+1)); done
which then would give me:
DNS.1 = domainname1.something.com
DNS.2 = domainname2.somehing.com
...
DNS.70 = and-so-forth-until 70
This could be useful, if you have for instance hundreds or thousands of lines where you have to add a incremental value per line.
Pimp my shell!
Got a tip from my colleague JB!
Want to refresh your terminal? Is it spring and time to freshen things up? Look at: http://ohmyz.sh/
Easy to install on Redhat:
yum -y install zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Result in my Putty in Windows 7:
Clear the cache on Redhat 5/6/7
On Redhat 5 and 6 we could empty the ldap cache with this command:
nscd -i group
and
nscd -i netgroup
But in Redhat 7 this doesn’t work. Instead one have to run this command:
sss_cache -E
here is more about sss_cache from Redhat:
Caddy webserver with proxy to docker :)
By my colleague Lennart:
https://lennart.w.uib.no/2018/02/16/fast-and-free-https-sites-with-caddy-webserver-with-proxy-to-docker-container-howto/
Cron every last Friday of month
We wanted to run a script every last Friday of the month. The script was set to remind people about certain issues. Friday is a nice day to be reminded of things, right?
Anyway, by putting this in the /etc/crontab file, one can achieve the request:
59 11 * * 5 username [ $(date +"\%m") -ne $(date -d 7days +"\%m") ] && $(cd /to/folder/; php myphpscript.php)
Which says:
At 11:59 on Friday run this command:
[ $(date +"\%m") -ne $(date -d 7days +"\%m") ] && $(cd /to/folder/; php myphpscript.php)
The first part:
[ $(date +"\%m") -ne $(date -d 7days +"\%m") ]
will test if the current month is equal to the month that will be in 7 days. If it is, it will generate something like:
01 -ne 01
which means it is current date is in January month (01), and it is compared (-ne = not equal to) the date in 7 days. If the result is:
01 -ne 02
one knows that the month in 7 days is February, hence the current date is the last Friday of this month 🙂
Reference: http://techsk.blogspot.no/2008/06/how-to-run-cronjob-on-last-friday-of.html