User Tools

Site Tools


unix_tricks

Unix Tricks

  • See the output of cron by doing
    sudo grep CRON /var/log/syslog
  • Count lines in files in current directory
    find . -type f | xargs cat | wc -l 
  • MTA errors in cron can be solved by installing Postfix aptitude install postfix. Select the Local only configuration.
  • tail -f /var/mail/<your_username>. do
    tail -f /var/mail/root

    to look at cron errors sent to root's email

  • bash scripts start with #!/bin/sh. If you get errors, you may have leading BOM characters (ef bb bf) in your file. Check this by doing
    head -n 1 myscript.sh | hexdump -C
  • 2>&1 means send stderr to stdout.
  • redirects stdout to afile.txt.
    echo test 1> afile.txt
  • To redirect stderr, you do
    echo test 2> afile.txt
unix_tricks.txt · Last modified: 2019/03/27 08:18 by 127.0.0.1