0
在Mac上定时强制终止应用(微信)
source link: https://blog.kelu.org/tech/2023/08/17/forcibly-terminating-an-application-wechat-on-mac-with-cron.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
上班经常一不小心微信聊了几句就忘记干正事了。写了一个定时任务,每个五分钟强制退出微信,拒绝成为摸鱼人!
这是脚本:
#!/bin/bash
pid=$(ps aux | grep "/Applications/WeChat.app/Contents/MacOS/WeChat" | grep -v "AppEx" | grep -v "grep" | awk '{print $2}')
if [ -n "$pid" ]; then
kill -9 "$pid"
echo "$(date '+%Y-%m-%d %H:%M:%S') - 微信已经被你狠狠地终结了!!!!!!!!!!!!!!!!!!!!!!"
else
echo "$(date '+%Y-%m-%d %H:%M:%S') - 微信已经不在了,你又多事了。"
fi
保存为文件 kill_wechat.sh
然后设置定时任务:
crontab -e
*/5 * * * * /Users/kelu/Workspace/cron/kill_wechat.sh >> /Users/kelu/Workspace/cron/kill_wechat.log
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK