Shadowsocks定时任务脚本

5,498 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 Thanks for the reply, according to Unraid Dev team, it may happen this year.
Metaldololity Metaldololity Whoa, that's really simple. You just save my time a lot. Thankyou!
HopoL HopoL Since you’ve got the backup, it’s actually pretty simple. Just restore the backup files to your new flash drive, then head over to the /config directory and edit the go file. Look for export UNRAID_GUID=xxxxxxxxxxxxxx and swap it with your new drive's GUID. That should do the trick!
Metaldololity Metaldololity Really apreciate for your fast respond, mate. I actually have the backup of the flashdrive (from regular unraid backup). The problem is, when i search on youtube tutorial about changing the failed flashdrive, the process need some sort of confirmation with an account in unraid (blacklist the old one -> whitelist the new one). Since i have a cracked unraid, i don't know how to register my new flashdrive as the correct one (and the system not asking me for the old failed flashdrive). Thanks in advance
HopoL HopoL Man, that's a tough spot to be in. Regularly backing up your /boot folder is super important for exactly this reason. If you don't have a backup and your flash drive is completely fried, your best bet is to Google some specific recovery guides or check the Unraid forums. There are ways to rebuild your config by identifying your parity and data drives, but it can be a bit of a process. Hope you can get it sorted!