linux shell 脚本写定时任务
来源:互联网 发布:桌面透明软件下载 编辑:程序博客网 时间:2024/06/06 03:54
1.创建shell脚本(在CommandSh目录下创建一个名为iwcap的shell文件)
touch /CommanSh/iwcap4.sh
2.编写shell脚本
vi iwcap4.sh
#!/bin/sh
result=`ifconfig | grep mon0 ` ---检查是否有名为mon0的端口,将返回结果赋值为result变量
date=$(date +%Y-%m-%d\ %X) ---获取系统时间
if [ "$result" = "" ]; then ----判断返回结果是否为空
iw phy phy0 interface add mon0 type monitor
sleep 2s
ifconfig mon0 up
sleep 1s
(iwcap4 -i mon0 -a 192.168.0.146 -p 10060 -t 60 -n 007&)
echo "$date mon0 create success " >> /CommandSh/CommandLog/iwcap4.log -----将输出日志不覆盖的写入/CommandSh/CommandLog/iwcap4.log文件中
else
echo "$date mon0 already exist " >> /CommandSh/CommandLog/iwcap4.log
fi
3.给写好的shell脚本添加可执行权限
chmod a+x /CommandSh/iwcap4.sh
4.指定crontab定时任务
crontab -e ----edit crontab
crontab -l -----list crontab
执行成功输出结果。
- linux shell 脚本写定时任务
- linux 定时执行shell脚本 定时任务
- linux shell脚本 -- 定时任务--备份日志
- shell脚本定时任务 ( linux系统)
- linux shell脚本 -- 定时任务--备份日志
- linux shell脚本 -- 定时任务--备份日志
- Linux 执行定时任务 shell脚本
- linux写定时任务
- Linux 定时任务执行Shell脚本【CentOS6.8】
- crontab和shell脚本,实现linux定时任务
- Linux定时shell脚本
- linux 下部署spring定时任务执行shell脚本,shell脚本执行spoon
- Linux定时任务执行脚本
- 定时任务中shell脚本的执行
- Shell脚本之crontab定时任务
- [shell]避免定时任务脚本的常见问题
- Shell脚本之crontab定时任务
- Shell脚本之crontab定时任务
- HIVE测试用的记录语句
- [leetcode] Reverse Integer
- Android conversion to dalvik format failed with error 1的解决办法
- 双向链表nyoj511
- hdu 1213 并查集入门题
- linux shell 脚本写定时任务
- android应用程序的混淆打包
- 【机器学习算法-python实现】K-means无监督学习实现分类
- 类模板中.h和.cpp的实现方法
- LeetCode OJ算法题(七):Reverse Integer
- POJ1035——Spell checker(字符串操作)
- 单片机IO短路连接问题
- 浏览器中对HTTP分析和篡改插件扩展
- POJ 3692:Kindergarten(最大团)