how to display the IP address of a virtual machine before logon

For testing or development purposes, I do a wide use of small linux virtual machines. After spawning a new guest (Virtualbox, VMWare or any other), often you want to log on over ssh but you don’t yet know its ip address. You need to login as ‘root’ in the console just to issue a quick ‘ifconfig’, and after writing down the address, you logout and connect with your comfortable terminal. In order to save some time and keystrokes, I put this in my rc.local of all my guest VMs: ...

May 5, 2014 · Andrea Manzini

dovecot: cleaning old Spam and Trash messages after some days

This script is useful to delete old messages in “Junk” mail folders (Spam, Trash) automatically after some days. adapted from these notes to work on debian/postfixadmin/dovecot #!/bin/bash # # itera sulle mailbox cancellando messaggi vecchi # per default, nel cestino 30gg e Spam 15 gg # # MySQL details HOST="127.0.0.1"; USER="put_here_your_mysql_user"; PWD="put_here_your_mysql_password"; MYSQL="/usr/bin/mysql"; # dovecot details DOVEADM="/usr/bin/doveadm"; TEMPFILE=$(/bin/mktemp) # Output sql to a file that we want to run echo "use postfixadmin; select username from mailbox" > $TEMPFILE # Run the query and get the results (adjust the path to mysql) results=$($MYSQL -h $HOST -u $USER -p$PWD -N < $TEMPFILE); # Loop through each row for row in $results do echo "Purging $row Trash and Junk mailbox..." # Purge expired Trash $DOVEADM -v expunge mailbox Trash -u $row savedbefore 30d # Purge expired Spam $DOVEADM -v expunge mailbox Spam -u $row savedbefore 15d done rm $TEMPFILE

March 5, 2014 · Andrea Manzini

number of physical sockets and cpu cores

a small script to check out the number of processors in your linux machine mandatory sample output:

September 14, 2013 · Andrea Manzini

run-parts e problemi di crontab

Mi e’ capitato di inserire degli script nelle varie directory /etc/cron.daily, /etc/cron.weekly ma di scoprire che questi script non vengono eseguiti. Il motivo e’ che il run-parts usato nelle Debian e derivate ignora i file che contengono un “.” (e quindi tutti quelli con l’estensione) Questo comportamento e’ documentato anche nella man page, e previene alcuni inconvenienti come l’esecuzione dei .bak ma lo scrivo anche qui per ricordarmelo … E forse potra’ essere utile a qualcun altro :) ...

December 6, 2012 · Andrea Manzini