looping a statement in ubuntu terminal
In the Ubuntu terminal, how do I loop a command like
python myscript.py
so that it runs every 15 minute开发者_如何学Cs?
you are looking for crontab rather than loop.
If you really need to schedule something, then you want crontab.
But if this is temporary (i.e. checking to see if a file has appeared or whatever), then here's how you could do this
while true ; do python myscript.py ; sleep 15m; done
This will execute forever ("while true") so you'll have to ctrl-c to cancel it when you are done.
Sounds like you want to use something like cron instead, but... if you are sure you want something to run in the same terminal-window every N minutes (or seconds, actually), you could use the 'watch' command.
watch -n 60 python myscripy.py
using crontab you can add an entry like */15 * * * * python /path/to/myscript.py
精彩评论