hello,
I have to mail the status of my server everyday.
How do I write a script which will help me do so??
I DO NOT want to use cron job. Is there some other alternative using which I can accomplish my task.
Thankyou
#!/bin/sh echo -n "Checking Raid... " RAID=`tw-cli /c0/u0 show status | cut -c17-31 | grep -ci OK` RAIDSTATUS=`tw-cli /c0/u0 show status | head -n1 | cut -c17-31` if [ $RAID -eq 0 ]; then VERIFYING=`tw-cli /c0/u0 show status | cut -c17-31 | grep -ci VERIFYING` REBUILDING=`tw-cli /c0/u0 show status | cut -c17-31 | grep -ci REBUILDING` if [ $VERIFYING -eq 1 ]; then CURRENTSTATUS=`tw-cli /c0/u0 show verifystatus | head -n1 | cut -c46-49` fi if [ $REBUILDING -eq 1 ]; then CURRENTSTATUS=`tw-cli /c0/u0 show rebuildstatus | head -n1 | cut -c47-50` fi echo "Raid is busy (Raid $RAIDSTATUS$CURRENTSTATUS)" exit 1 fi echo "Raid is idle (Raid $RAIDSTATUS)" echo -n "Checking for logged in Users... " USERS=`who | wc -l` if [ $USERS -gt 0 ]; then echo "Users online" exit 1 fi echo "None logged in"
root@monster:~# crontab -l # Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command */10 * * * * /root/sd.sh | logger */30 * * * * /root/dropbox.sh > /dev/null
Mar 21 09:10:01 monster /USR/SBIN/CRON[3998]: (root) CMD (/root/sd.sh | logger) Mar 21 09:10:01 monster logger: Checking Raid... Raid is busy (Raid ) Mar 21 09:17:01 monster /USR/SBIN/CRON[4045]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly) Mar 21 09:20:01 monster /USR/SBIN/CRON[4105]: (root) CMD (/root/sd.sh | logger) Mar 21 09:20:01 monster logger: Checking Raid... Raid is busy (Raid ) Mar 21 09:30:01 monster /USR/SBIN/CRON[4266]: (root) CMD (/root/sd.sh | logger) Mar 21 09:30:01 monster /USR/SBIN/CRON[4265]: (root) CMD (/root/dropbox.sh > /dev/null) Mar 21 09:30:01 monster logger: Checking Raid... Raid is busy (Raid )
root@monster:~# sh /root/sd.sh Checking Raid... Raid is idle (Raid OK) Checking for logged in Users... Users online root@monster:~#
#!/bin/sh /bin/ps -ef |/bin/grep script2.sh |/bin/grep -v $$ > /dev/null 2>&1 if [ $? -ne 0 ] then /usr/bin/nohup /home/user1/script2.sh & fi
#!/bin/ksh userid="chansd" filename="/apps/log/check.txt" while true ;do touch $filename pass=`/apps/eDMZ/call_st.ksh $userid` sleep 20 rm $filename done
#!/bin/ksh filename="/apps/log/check.txt" if [ -f "${filename}" ] then if test "`find $filename -mmin +2`" then echo "script is not working ! Please act on it" | mail -s "Script is not working" Example@mail.com fi else exit 1 fi
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command */10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav
/usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav
function tx_unreachable_msg() { LOGLINE="[$DATE] no ip service unreachable" typewriter "$NOIPSERVICE niet bereikbaar" .1 sleep 1 typewriter "Mail wordt verzonden naar $email" .1 mail -s "NO ip mail error" "$email"<<EOF dynupdate.no-ip.com niet bereikbaar @ $DATE EOF }