Univers Libre

Get verbose output from an already launched cp/mv/rsync process

Written on 27 May 2015, 19:26 CEST
Tags: sysadmin.

This could be a bit obvious for others sysadmins, but I use this trick quite often and it's really helpfull.

Imagine you connect on a server and see a running process (a cronjob for example) doing some file copy operations, running for a while and launched without -v option (or you can't see his stdout).

Or imagine you launched a big cp/mv (from a partition to another)/rsync or whatever, you know it will probably run for a while, but you missed to add the -v option.

No problem, here is how we could get an equivalent with strace:

strace -p $(pidof cp) 2>&1 |grep open

Or for a rm:

strace -p $(pidof rm) 2>&1 |grep unlink

If you want just to see the current file your command is currently on:

lsof -p $(pidof cp)