T
T
Taras Serevann2015-04-25 11:30:20
linux
Taras Serevann, 2015-04-25 11:30:20

Can a bash script be causing the server to hang?

Hello.
I have the following bash script

#!/bin/bash
while [ 1 ]; do
xdotool windowactivate 62914742 sleep 1 windowfocus 62914742 sleep 1
xdotool mousemove  632 142 sleep 2 click 1 sleep 2 type "my text"
echo "-> done" 
sleep 300
done

it runs on a rather weak machine and, by my design, executes xdotool commands every 5 minutes. But, as usual, something goes wrong: after a few hours the computer freezes and the script stops executing. Is it because of the bash script? How to fix this problem, perhaps instead of an eternal loop it is better to use cron?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2015-04-25
@melkij

Without this script does not hang?
Is there anything interesting in the logs at this time?
It is really more logical to hang up the task every 5 minutes on kroner, but the userspace process should not hang up the machine in any case.

S
Sergey, 2015-04-25
@butteff

Save this code to script.sh file:

xdotool windowactivate 62914742 sleep 1 windowfocus 62914742 sleep 1
xdotool mousemove  632 142 sleep 2 click 1 sleep 2 type "my text"
echo "-> done"

Make it executable:
Go to cron settings:
Create a cron entry to run every 5 minutes:
*/5 * * * * /path/to/script.sh

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question