B
B
borg3332019-08-10 20:06:20
linux
borg333, 2019-08-10 20:06:20

Running watch via sh, how?

Hello.
Given: 2 script.sh scripts whose purpose is to generate output from curl
Task: run two scripts at a specified frequency (2s)
Solution: run through watch

watch -n 2 "/root/script1.sh | tee -a 1.log" &>/dev/null &
watch -n 2 "/root/script2.sh | tee -a 2.log" &>/dev/null &

Everything is ok with this, but at some point the watch process crashes and there is a need to restart it.
I made a sh script to run it by cron:
#!/bin/bash
if ! (pidof watch)
then
    watch -n 2 "/root/script1.sh | tee -a 1.log" &>/dev/null &
    watch -n 2 "/root/script2.sh | tee -a 2.log" &>/dev/null &
    echo "Watch restarted" | mail -s "CRON: Watch was restarted" [email protected]
fi

If you run it manually, then everything is OK, if through cron (* * * * * root /root/watch-restart.sh), then watch is not processed. Did not notice any errors, the letter is sent.
What could be the problem?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
taliano, 2019-08-11
@taliano

Support the crutch with another crutch?
Isn't it easier to run curl c, for example, --progress-bar?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question