Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: What are your best command-line time- and toil-saving tips?
1 point by gjvc on Nov 6, 2020 | hide | past | favorite | 3 comments



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.)


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.)


neatly reformat columnar data with

    column -t




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: