Linux命令行指令
ps -ef| grep java
crontab -e
chmod 777 export.sh
curl http://www.baidu.com
#!/bin/bash
export LANG="en_US.UTF-8"
while [ 1 ]; do
a=`lsof -i:6380 |grep 'redis-ser' |grep -v grep |grep -v agent|sort | tail -1 | cut -f 1 -d' '`
if [ "$a" != 'redis-ser' ];then
{ ./redis-server /usr/redis/redis2.conf &
echo redis restart at `date` >> /usr/redis/redis.log
}
fi
sleep 5
done
文件权限参考
Linux脚本代码
21 */1 * * * cd /home/crawler/qutoutiaoCrawler/ && ./export.sh > /dev/null
每个小时的21分运行/home/crawler/qutoutiaoCrawler/下的export.sh文件,并把缓存丢入/dev/null
/dev/null是一个空设备
{minute} {hour} {day-of-month} {month} {day-of-week} {full-path-to-shell-script}
minute: 区间为 0 – 59
hour: 区间为0 – 23
day-of-month: 区间为0 – 31
month: 区间为1 – 12. 1 是1月. 12是12月.
Day-of-week: 区间为0 – 7. 周日可以是0或7.