Linux 开机监控

问题: (开机运行的时候找不到camshot程序,所以我给camshot加上了完全路径。)

最主要参考了奶牛的博客, 谢谢啦:

http://www.nenew.net/linux-security-arch-linux-auto-mail-notification.html

http://www.nenew.net/linux-camera-shot-camshot.html


结合我转载的Mutt发送邮件,camshot 在命令行下拍照以及让脚本开机运行。

可以做出一个很简单的开机监控应用。


capture.sh 内容如下:

#!/bin/sh

#chkconfig:23456 99 05
#send email to $dst \ 
#with $subject $attach

#variable setting
dst=chj90220@126.com
subject=`date` 
subject="$subject: someone startup you computer"
content="someone startup you computer.His/Her image is in attachment.please check"
attach=date_$$.bmp
bmppipe="pipefile"
logout=/run/media/huntinux/F/linux-space/log/capturelog.out
logerr=/run/media/huntinux/F/linux-space/log/capturelog.err

# get picture through camera
/run/media/huntinux/F/huntinux_bin/camshot-1.0/camshot-read-only/camshot -W 320 -H 240 -p ./$bmppipe 1>$logout 2>$logerr &
sleep 5
cat $bmppipe >$attach

# send picture to email $dst
echo "$content" | mutt "$dst" -s "$subject" -a "$attach"

# close camshot 
kill `ps aux |grep camshot|grep -v grep|awk -F " " '{printf $2}'`

#rm -rf $attach
exit 0



测试成功后,将其开机自动启动即可。

# chmod +x captuer.sh

# cp capture.sh /etc/init.d/

# chkconfig --add capture.sh

# chkconfig --list capture.sh 

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

capture.sh         0:off    1:off    2:on    3:on    4:on    5:on    6:on

重启即可在邮箱看到邮件。看看里面有没有照片。哈哈




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值