Created
August 11, 2014 05:47
-
-
Save anonymous/35ef83e80c122ac781f5 to your computer and use it in GitHub Desktop.
嵌入式 busybox 使用 cronjob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# file: /root/check_3g_network.sh | |
LOGGER_TAG="3g_network_check" | |
ping -c 5 www.baidu.com > /dev/null | |
if [ $? -eq 0 ]; then | |
logger -t LOGGER_TAG "3g network is connection." | |
else | |
logger -t LOGGER_TAG "3g network is disconnection." | |
logger -t LOGGER_TAG "trying kill exist connection process." | |
kill `ps | pgrep "[p]ppd"` | |
logger -t LOGGER_TAG "kill exist connection process successfully." | |
logger -t LOGGER_TAG "try reconnect 3g network" | |
pppd call wcdma-usb2 &> /dev/null | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: /etc/init.d/rcS | |
# connection wcdma 3g network on boot | |
pppd call wcdma-usb2 | |
# 创建 crontabs 工作目录 | |
mkdir -p /var/spool/cron/crontabs | |
# 复制 /etc/crontabs 的自动任务到 crontabs 工作目录 | |
cp -p /etc/crontabs/root /var/spool/cron/crontabs | |
# 给 crontabs 工作目录加权限 | |
chmod 777 /var/spool/cron/crontabs/root | |
# 启动 crond 守护进程 | |
crond | |
# 卖个萌 | |
echo "cp cron config file to /var/spool/cron/crontabs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: /etc/crontabs/root | |
# m minute | |
# h hour | |
# dom day of month | |
# mon mouth | |
# dow day of week | |
# m h dom mon dow | |
* * * * * /root/check_3g_network.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment