Skip to content

Instantly share code, notes, and snippets.

@hamidzr
Last active November 17, 2018 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamidzr/17cc0520d0ae17812715cf5cc13d075d to your computer and use it in GitHub Desktop.
Save hamidzr/17cc0520d0ae17812715cf5cc13d075d to your computer and use it in GitHub Desktop.
simple sendmail alternative to catch cron logs
#!/bin/bash
# simple sendmail
date_str=`date +%y-%m-%d--%H-%M-%S`
rand=$((RANDOM % 1000))
hostname=$(hostname | tr '/:' '\057\072')
fname=$date_str.$rand.$hostname
target_dir=SET_DESIRED_DIR
# safety measure: do not overwrite existing mail
set -o noclobber
cat > $target_dir/$fname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment