Skip to content

Instantly share code, notes, and snippets.

@hexathos
Last active April 3, 2018 04:40
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 hexathos/a451b3b6dab25c50c1941950594b94b2 to your computer and use it in GitHub Desktop.
Save hexathos/a451b3b6dab25c50c1941950594b94b2 to your computer and use it in GitHub Desktop.
Morning Tweets
function checkForPid {
lockfile=${1}
if [ -f ${lockfile} ] ; then
runningpid=$(cat ${lockfile})
if ps -p${runningpid} >/dev/null
then
runningpid=$(cat ${lockfile})
echo "${0##*/} wird bereits ausgeführt (PID ${runningpid})"
ps -p${runningpid} -u
exit 1
else
removeLockFile ${lockfile}
echo $$ > ${lockfile}
fi
fi
}
function removeLockFile {
lockfile=${1}
if [ -f ${lockfile} ] ; then
rm ${lockfile}
fi
}
#!/bin/bash
lockfileGlobal=/tmp/hx_lock_${0##*/}
if [ -f /etc/profile ] ; then
source /etc/profile
fi
source hxfunctions-reduced.sh
if [ ! -f ${lockfileGlobal} ]; then
echo $$ > ${lockfileGlobal}
else
checkForPid ${lockfileGlobal}
fi
echo ${0##*/}
if [ ! -d ${HOME}/logs ] ; then
mkdir -p ${HOME}/logs
fi
logfile=${HOME}/logs/${0##*/}.log
echo $(date) starting >>${logfile}
sleeptime=$[RANDOM%10]
echo $(date) sleeping ${sleeptime}m >>${logfile}
sleep ${sleeptime}m
text=$(shuf -n1 ${HOME}/documents/morningtweets.txt)
echo $(date) picked ${text} >>${logfile}
${HOME}/bin/oysttyer.pl -status="${text}" >>${logfile}
removeLockFile ${lockfileGlobal}
[mɔɪ̯n] ☀
Guten Morgen
Morgähn
Oel ngati kameie
Live long and prosper! 🖖
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment