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. ZooKeeper常见问题(转)

    这段时间来,也在和公司里的一些同学交流使用zk的心得,整理了一些常见的zookeeper问题.这个页面的目标是解答一些zk常见的使用问题,同时也让大家明确zk不能干什么.页面会一直更新. 客户端 1. ...

  2. js工具类大全

    /********** 日期处理函数 *********/<script type="text/javascript" src="${springMacroRequ ...

  3. Java程序员面试失败的5大原因

    下面是Java程序员面试失败最有可能的5大原因,当然也许这5点原因适用于所有的程序员,所以,如果你是程序员,请认真阅读以下内容. #1 说得太少 尤其是那些开放式的问题,如“请介绍下你自己”或“请讲一 ...

  4. OpenGIS Simple feature access

    OGIS规范定义的几何对象定义 Curve:A Curve is a 1-dimensional geometric object usually stored as a sequence of Po ...

  5. python判断key是否在字典用in不用has_key

    小测试 in del.py import datetime cur = datetime.datetime.now() num = 1 a_list = {"a":1, " ...

  6. javaScript学习之ajax

    一.xmlHttpRequest对象的创建 ajax的核心的XMLHttpRequest对象,下面的代码给出了兼容各个浏览器的方法实现 function createXHR(){ if(typeof ...

  7. 让show parameter显示隐含参数(12C)

    1.创建视图show_hidden_v$parameter create or replace view show_hidden_v$parameter (inst_id,NUM , NAME , T ...

  8. Oracle Flashback Technologies - 闪回查询

    Oracle Flashback Technologies - 闪回查询 查看表中,某行数据的修改记录 #创建一个表,并插入和修改数据 SQL> create table y3(id )); T ...

  9. mysqld_multi部署mysql单机多实例

    1.安装gcc-c++.ncurses依赖包 # yum install gcc-c++ ncurses-devel 2.安装cmake,用来编译mysql # tar -xvf cmake-3.2. ...

  10. maven增加Spring

    对于javax.annotation,spring某些注解要用的,比如:@Resource.   使用Maven管理基本的Spring依赖关系 Spring被设计为可高度模块化的 —— 使用Sprin ...