Cc L Cc L - 6 months ago 23
Bash Question

Shell Script: execute & repeat a python program need extra command

every one,I have to run this python command

python manage.py rebuild_index
at certain time and rerun again.Therefore,I am trying the shell script to run it.However,when run this python command .I have to choice
y
to continue

enter image description here

my


run_rebuild.sh


#!/bin/sh
python manage.py rebuild_index


moreover ,how can I let the run_rebuild.sh rerun again after every 60 second??

Answer

You can use yes for this:

yes | python /manage.py rebuild_index

One way to run your script every minute:

while yes | python /manage.py rebuild_index; do
  sleep 60
done

The above will run your script every 60 second until it fails.

Comments