Running a cron every 30 seconds

后端 未结 19 1267
面向向阳花
面向向阳花 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:29

    write one shell script create .sh file

    nano every30second.sh

    and write script

    #!/bin/bash
    For  (( i=1; i <= 2; i++ ))
    do
        write Command here
        sleep 30
    done
    

    then set cron for this script crontab -e

    (* * * * * /home/username/every30second.sh)

    this cron call .sh file in every 1 min & in the .sh file command is run 2 times in 1 min

    if you want run script for 5 seconds then replace 30 by 5 and change for loop like this: For (( i=1; i <= 12; i++ ))

    when you select for any second then calculate 60/your second and write in For loop

提交回复
热议问题