Run cron job in every 20 second
I added a cron job , but I found that even set * * * * * ~my_cronjob , it only only it at EVERY MINUTE , if I want it run at every 20 second , can advise what can i do ? thx
|
Why don't you run 3 cronjobs, where the second sleeps for 20 seconds and the third for 40 seconds before doing whatever you want it to.
|
You can create a script that runs your command, sleeps for 20 seconds and so on. Something like:
Code:
#!/bin/sh |
Quote:
|
What about a script that sits in the background spawning off child processes every 20 seconds?
If it's coded correctly the children should exit having completed and not hang your box. However, if there is an error, you're in for a world of hurt. |
@ust: Can you explain what it is you want to run every 20 seconds?
|
billymayday has the right approach if you really need to run a script/command every 20 seconds with cron. It would look something like this:
Code:
* * * * * /path/to/script |
Quote:
Code:
#!/bin/bash |
Quote:
|
Quote:
|
Quote:
The only modifications I made to the script was these:
I don't know if that answer your question. |
No, that explains it.
|
cron job every 20 seconds
Quote:
|
execute a script every five seconds, example
Thanks to your information i had execute a script every 5 sec.
# Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed */1 * * * * root sleep 5; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 10; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 15; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 20; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 25; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 30; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 35; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 40; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root slepp 45; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 50; echo "script ejecutado $(date)" >> /tmp/salida.txt */1 * * * * root sleep 55; echo "script ejecutado $(date)" >> /tmp/salida.txt |
All times are GMT -5. The time now is 01:19 AM. |