HACKER Q&A
📣 gjvc

What are your best command-line time- and toil-saving tips?


What are your best command-line time- and toil-saving tips?


  👤 gjvc Accepted Answer ✓
For long-running jobs which need to be killed after a timeout, and when you also need to ensure there is only ever a single instance, use something like this:

   /usr/bin/flock --nonblock /var/tmp/${LOGNAME}.sleep \
       /usr/bin/timeout --signal KILL 5 \
           /usr/bin/sleep 10
Where your command goes in place of the "/usr/bin/sleep 10" (If this is not immediately obvious, to see it in action, open two terminals on the same host, and try running the above command in both at the same time.)

👤 gjvc
rsync-pro-tip: use a trailing slash on both the source/ and the target/ and you'll never go wrong:

    rsync /some/where/local/ host:/another/place/remote/
The contents of local/ go into remote/

(I put this in another comment and it got some votes, which gave me the idea to solicit other gems.)


👤 gjvc
neatly reformat columnar data with

    column -t