Last active
April 3, 2018 04:40
Morning Tweets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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