redirect output of an already running process

Long story short: you have launched your script/program but forgot to redirect the output to a file for later inspection. #!/usr/bin/python3 #sample endless running program that prints to stdout import time,datetime while True: print(datetime.datetime.now().time()) time.sleep(1) Using GNU Debugger you can re-attach to the process, then invoke the creation of a logfile and duplicate the file descriptor to make the system send the data to the new file, instead of the terminal: ...

April 24, 2015 · 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

generare comandi di creazione utenze a partire da un passwd

A volte e’ necessario replicare le utenze con gli stessi parametri su piu’ server linux diversi. Perche’ farlo a mano ? Se sono tanti e’ un lavoro noioso e potremmo anche commettere degli errori. Ecco un semplice one-liner che fa il parsing di un file /etc/passwd e genera i corrispondenti comandi useradd awk -F: '{printf "useradd -m -u%s -g%s -d%s -s%s %s\n" , $3,$4,$6,$7,$1}' /etc/passwd Ovviamente l’output puo’ essere comodamente filtrato con grep, usato via copy&paste, inserito in uno script, eccetera… ...

November 23, 2012 · Andrea Manzini