Running a cron every 30 seconds

后端 未结 19 1182
面向向阳花
面向向阳花 2020-11-22 10:56

Ok so I have a cron that I need to run every 30 seconds.

Here is what I have:

*/30 * * * * /bin/bash -l -c \'cd /srv/last_song/releases/2012030813315         


        
19条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 11:37

    Crontab job can be used to schedule a job in minutes/hours/days, but not in seconds. The alternative :

    Create a script to execute every 30 seconds:

    #!/bin/bash
    # 30sec.sh
    
    for COUNT in `seq 29` ; do
      cp /application/tmp/* /home/test
      sleep 30
    done
    

    Use crontab -e and a crontab to execute this script:

    * * * * * /home/test/30sec.sh > /dev/null
    

提交回复
热议问题