![]() For example, if you do a sleep 10 between commands, and the command takes 2 seconds to run, then it's going to run every 12 seconds if it takes a variable amount of time to run, then over the long term the time when it runs can be unpredictable. One problem that all the answers posted so far have is that the time the command is executed can drift. ![]() % repeat -1 5 echo "This will get echoed every 5 seconds forever." The above examples would then become: % repeat 100 0 echo "I will not automate this punishment." PS: Maybe a better way to do this would be to generalize repeat to take both the number of times to repeat (with -1 meaning infinity) and the number of seconds to sleep between repeats. If not, feel free to post a solution in your favorite scripting language. I know it's like a 2-line Perl or Python script, but maybe there's a more standard way to do this. I thought I'd ask if such a thing exists before I write it. For example, % forever 5 echo "This will get echoed every 5 seconds forever and ever." I'd like a similar command – let's call it forever – that works similarly except the first argument is the number of seconds to pause between repeats, and it repeats forever. Will echo the given string 100 times and then stop. There's a built-in Unix command repeat whose first argument is the number of times to repeat a command, where the command (with any arguments) is specified by the remaining arguments to repeat.įor example, % repeat 100 echo "I will not automate this punishment."
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |