Shadowsocks定时任务脚本

5,489 views次阅读
没有评论

最近发现我的 VPS 后台 Shadowsocks进程莫名其妙的关闭。

 

然后就找到了下面的 SS 定时任务脚本,先记录下来以后慢慢看。

 

wget --no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-crond.sh

chmod +x shadowsocks-crond.sh

 

shadowsocks-crond  备份一下 免得以后找不到了。

 

此时便将脚本 shadowsocks-crond.sh 下载回来并赋予执行权限了。

后面将此脚本扔到 Linux 的定时任务 cron 里就搞定了。

cron 是一个 Linux 下的定时执行工具,可以在无需人工干预的情况下运行作业。由于 Cron 是 Linux 的内置服务,多数情况下它不是自动启动的,可以用以下的方法启动、关闭这个服务。

/etc/init.d/crond start //启动服务

/etc/init.d/crond stop //关闭服务

/etc/init.d/crond restart //重启服务

/etc/init.d/crond reload //重新载入配置

 

编辑 /etc/crontab 文件配置 cron

默认的是以下这样的:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

 

只需在最后追加如下一行:

*/5 * * * * root bash /root/shadowsocks-crond.sh

 

然后保存退出。

以上表示每 5 分钟,root 用户执行一下脚本 /root/shadowsocks-crond.sh

 

注意脚本要写完整路径。

这样系统就会每 5 分钟检查一下 Shadowsocks 进程是否存在了,如果不存在了会自动重新启动。

脚本每次运行会写日志的,日志完整路径如下:

/var/log/shadowsocks-crond.log

正文完
 0
HopoL
版权声明:本站原创文章,由 HopoL 于2016-01-20发表,共计1115字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)

HopoL's Blog

文章搜索
最新评论
阿龙 阿龙 谢谢大佬分享
MickeyDee MickeyDee Cancell that, figured it out and it works, Much appriciated .
MickeyDee MickeyDee Hi Thanks for sharing, please clarify, do you mean Rename the folder "unraider-7.2.0" to unraider and copy it to the config . Thanks
lzdwudi lzdwudi 我也想试试 但我目前的版本是6.12.13 我不敢做大的动作
wice222 wice222 archive is demaged
tstUser01 tstUser01 Thanks for sharing!
saisu saisu how to install from scratch for noobs like me please :D What is GUID ??
Adrian Adrian How update works? Should we rename unraider file, do the update and rename back? from 7.2.0 to 7.2.1
步兵 步兵 哈喽 想请问一下文件是从老毛子网站下载的吗 因为怕有挖矿的后门 所以想了解确认一下 感谢
hpapagaj hpapagaj Thank you.