crontab:

#!/bin/bash

step=$   #每多少秒执行一次

for (( i = ; i < ; i++ )); do
date +%Y%m%d' '%H:%M:%S >> s.log
curl https://car.etaiping.com:6004/ecms2/portal/gwzt/carType &> s.log
echo >> s.log
sleep $step
done

log backup:

#!/bin/bash
#author:xiluhua
#since: #####################################################################
# $:the frequency to do log backup
# $:only if the number of log files reach v_count,log files will be backuped
# $:target directory that needs to do log backup
# $:the directory to put bakuped logs
##################################################################### v_step=$
v_count=$
v_targDir=$
v_histDir=$ if [ -z $v_targDir ]
then
echo "exception: argu 'v_targDir' is empty!"
exit
fi if [ -d $v_targDir ]
then
# do nothing
echo > /dev/null
else
echo "exception: argu 'v_targDir' is not exist!"
exit
fi if [ -z $v_histDir ]
then
echo "exception: argu 'v_histDir' is empty!"
exit
fi if [ -d $v_histDir ]
then
# this is the key step to make the .gz file without directory
cd $v_histDir
else
echo "exception: argu 'v_histDir' is not exist!"
exit
fi if [ -z $v_step ]
then
echo "v_step is empty!"
exit
fi if [ -z $v_count ]
then
echo "exception: argu 'v_count' is empty!"
exit
fi let isProcExist=
# recycle endlessly
while [ "" = "" ]
do
# if same job process already exists,sleep sometime
while [ "" = "" ]
do
if [ $isProcExist -gt ]
then
sleep $v_step
else
break
fi
done let isProcExist= files=$(find $v_targDir -name "*.log")
count=$(ls $files | wc -l) #echo "count:"$count
#echo "v_count:"$v_count if [ $count -ge $v_count ]
then
dir=$(date +%Y%m%d'_'%H%M%S)
# give the value to bakDir
bakDir=$dir mkdir $bakDir
mv $files $bakDir
#echo $bakDir'.tar.gz'
tar -Pczf $bakDir'.tar.gz' $bakDir if [ $bakDir = "/" ]
then
clear
else
rm -r $bakDir
fi
fi
sleep $v_step let isProcExist=
done

autoCreateFile:

#!/bin/bash
#author:xiluhua
#since: v_step=$
if [ -z $v_step ]
then
echo "exception: argu 'v_step' is empty!"
exit
fi cd ~/auto for (( i = ; i < ; i=(i+step) )); do
file1=$(date +%Y%m%d'_'%H%M%S)'_1.log'
file2=$(date +%Y%m%d'_'%H%M%S)'_2.log'
file3=$(date +%Y%m%d'_'%H%M%S)'_3.log' touch $file1 $file2 $file3
sleep $v_step
done

batchRename:

#!/bin/bash
#author:xiluhua
#since:
#####################################################################
# $:the dir to do batch file rename
# $:name before rename
# $:name after rename
##################################################################### dir=$
targ=$
repl=$ #check arguments is not empty and valid
if [ -z $dir ]
then
echo "exception: argu 'dir' is empty!"
exit
fi if [ $dir = "/" ]
then
echo "exception: argu 'dir' is invalid!"
exit
fi if [ -d $dir ]
then
cd $dir
else
echo "exception: argu 'dir' is not exist!"
exit
fi if [ -z $targ ]
then
echo "exception: argu 'targ' is empty!"
exit
fi if [ -z $repl ]
then
echo "exception: argu repl is empty!"
exit
fi # begin the main business
for i in $(ls *."$targ");do
# echo $i
tmp=${i/"$targ"/"$repl"}
# echo $tmp
mv -f $i $tmp
done

crontab实现每秒执行的更多相关文章

  1. Linux crontab 实现每秒执行

    Linux crontab 实现每秒执行 linux crontab 命令,最小的执行时间是一分钟.如需要在小于一分钟内重复执行,可以有两个方法实现. 1.使用延时来实现每N秒执行 创建一个php做执 ...

  2. linux crontab 实现每秒执行(转)

    linux crontab 命令,最小的执行时间是一分钟.如需要在小于一分钟内重复执行,可以有两个方法实现. 1.使用延时来实现每N秒执行 创建一个php做执行动作,非常简单,就是把当前时间写入log ...

  3. linux中crontab实现以秒执行任务

    用crontab+sleep实现以秒执行任务 crontab -e * * * * * /bin/date >>/tmp/date.txt * * * * * sleep 10s; /bi ...

  4. 【Linux】 crontab 实现每秒执行

    linux crontab 命令,最小的执行时间是一分钟, 如果要在小于一分钟执行.就要换个方法来实现 1   crontab 的延时: 原理:通过延时方法 sleep N  来实现每N秒执行. cr ...

  5. linux crontab 实现每秒执行的实例

    linux crontab 命令,最小的执行时间是一分钟.如需要在小于一分钟内重复执行,可以有两个方法实现. 1.使用延时来实现每N秒执行 原理:通过延时方法 sleep N  来实现每N秒执行. 创 ...

  6. crontab每秒执行URL接口

    首先crontab -e打开进行编辑 添加以下代码(默认为每秒执行一次脚本crontab.sh): * * * * * /bin/sh /var/www/aa/crontab.sh 下面是/var/w ...

  7. 如何让linux定时任务crontab按秒执行

    如何让linux定时任务crontab按秒执行? linux定时任务crontab最小执行时间单位为分钟如果想以秒为单位执行,应该如何设置呢?思路 正常情况是在crontab中直接定义要执行的任务,现 ...

  8. 每10秒执行定时任务-crontab

    * * * * * /data/crontab.sh * * * * * sleep 10; /data/crontab.sh * * * * * sleep 20; /data/crontab.sh ...

  9. [日常] crontab的秒执行和串行化和多进程实现

    1. crontab的最低运行频率是,按照每分钟执行一次,通过在脚本中简单实现按秒级别运行 比如这条cron规则 , 每分钟执行一次脚本 * * * * * php /var/www/html/tes ...

随机推荐

  1. Xib的使用与File'Owner总结

    Xib的使用与File'Owner总结 一.XIB的适用范围 xib(也叫Nib)与storyboard一样是用来描述界面的. storyboard描述的是比较大型的,大范围.适合描述界面跳转等. 二 ...

  2. Android Studio IDE 主题设置

    1.界面主题设置,如下图: 2.代码字体设置,如下图:

  3. os模块 关于路径问题使用

    os.getcwd() 获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录:相当于shell下cd os.curd ...

  4. Go 性能分析

    上线一定要用压力测试,才能知道自己的承受度是多少,不然出了问题,就各种排查. http://www.tuicool.com/articles/NVRJrm 通过jmeter压力测试,发现打印请求参数消 ...

  5. 0428—Scrum团队成立及《构建之法》第六、七章读后感

    5.Scrum团队成立 5.1 团队名称:喳喳 团队目标:突破渣渣 团队口号:吱吱喳喳 团队照: 5.2 角色分配 产品负责人: 112冯婉莹 Scrum Master:109张鑫相 PM项目经理:1 ...

  6. Lintcode: Count of Smaller Number

    Give you an integer array (index from 0 to n-1, where n is the size of this array, value from 0 to 1 ...

  7. Java中几种日志方案

    .本文记录Java中几种常用的日志解决方案 0x01 Log4j .这应该是一个比较老牌的日志方案了,配置也比较简单,步骤如下 1)添加对应依赖,比如 Gradle 中 dependencies { ...

  8. 数据库 SQL基础

    数据库是用来存取数据的. 数据库类型: ACESS(比较小,存储少) SQL SERVER (.net) MySQL Oracle(java) 数据库:服务.界面 服务是可以操作的后台的程序. 界面是 ...

  9. have you declared this activity in your AndroidManifest.xml

    对于那些刚开始接触安卓的开发者来说,遇到这个问题再正常不过了,出现这种问题的原因大概可分为: 1.android的四大组件都必须在AndroidMainifest.xml里面声明,所以首先看看有没有在 ...

  10. Thread create 创建进程

    #include "windows.h" #include "iostream" #include "stdio.h" void Start ...