博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux下用crontab起定时任务
阅读量:6968 次
发布时间:2019-06-27

本文共 410 字,大约阅读时间需要 1 分钟。

hot3.png

1. 先写个脚本当做任务 memfree.sh:

#!/usr/bin/sh

leftMem=`free | tr [:blank:] \\\n | grep [0-9] | sed -n '3p'`

#echo $leftMem;
if [ $leftMem -lt 524288 ]; then
    sync
    echo 1 > /proc/sys/vm/drop_caches
fi
 

2. 对shell脚本添加执行权限。

chmod 755 memfree.sh

 

3.  添加到定时任务:

 crontab -e (编写后保存即可生效):

*/5 * * * * /bin/bash /data/shell/getdata.sh >/dev/null 2>&1

每5分钟执行一次

 

4、查看是否添加进去

crontab -l 

095619_fJ9f_2376274.png

 

转载于:https://my.oschina.net/michaelshu/blog/1800764

你可能感兴趣的文章
your windows password does not match your Notes password
查看>>
TCP: time wait bucket table overflow解决方法
查看>>
CSS样式中设置table的cellspacing属性
查看>>
The method getTextContent() is undefined for the type Node
查看>>
iPhone动画属性详解
查看>>
fatal error: 'openssl/err.h' file not found
查看>>
zabbix实现 SAS 6/iR 型号 Raid信息监控
查看>>
RHEL Centos7 Yum网络源与光盘源设置
查看>>
一条sql语句实现一维表生成二维表格
查看>>
我的友情链接
查看>>
从“赢”字诠释解读成功的必备要素(一)
查看>>
面试心得
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
2018-08-16期 HBase全分布模式集群及HMaster HA安装部署
查看>>
docker中的容器互联-linking系统
查看>>
Linux学习之CentOS(二十一)--Linux系统启动详解
查看>>
escape()、encodeURI()、encodeURIComponent()区别详解
查看>>
AgileEAS.NET5.0-界面设计器-使用说明书(上)
查看>>
g80 architecture overview
查看>>