История изменений
Исправление orm-i-auga, (текущая версия) :
Здесь нужно отслеживать что за компом уже никто не работает Н-минут
Используй xprintidle. Я раньше так майнер у себя запускал.
#!/bin/sh
TRIGGER=6000000
PROGRAM=name
PROGRAM_PATH=/path/
PROGRAM_FULL_PATH=$PROGRAM_PATH$PROGRAM
PROGRAM_OPTS="-o bla bla bla"
export DISPLAY=:0
IDLE=$(xprintidle)
DATETIME=$(date +"%F %T")
RUNNED_PID=$(ps -e | grep $PROGRAM | awk '{print $1}')
if [ $IDLE -ge $TRIGGER ]; then
if [ -z $RUNNED_PID ]; then
echo "$DATETIME Starting $PROGRAM (idle = $IDLE ms, trigger = $TRIGGER ms)"
screen -d -m -A -S program_title $PROGRAM_FULL_PATH $PROGRAM_OPTS
else
echo "$DATETIME Already started $PROGRAM (PID = $RUNNED_PID, idle = $IDLE ms, trigger = $TRIGGER ms)"
fi
else
if [ ! -z $RUNNED_PID ]; then
echo "$DATETIME Stopping $PROGRAM (PID = $RUNNED_PID, idle = $IDLE ms, trigger = $TRIGGER ms)"
killall $PROGRAM
else
echo "$DATETIME Already stopped $PROGRAM (idle = $IDLE ms, trigger = $TRIGGER ms)"
fi
fi
Исходная версия orm-i-auga, :
Здесь нужно отслеживать что за компом уже никто не работает Н-минут
Используй xprintidle. Я раньше так майнер у себя запускал.
#!/bin/sh
TRIGGER=6000000
PROGRAM=name
PROGRAM_PATH=/path/
PROGRAM_FULL_PATH=$PROGRAM_PATH$PROGRAM
PROGRAM_OPTS="-o bla bla bla"
export DISPLAY=:0
IDLE=$(xprintidle)
DATETIME=$(date +"%F %T")
RUNNED_PID=$(ps -e | grep $PROGRAM | awk '{print $1}')
if [ $IDLE -ge $TRIGGER ]; then
if [ -z $RUNNED_PID ]; then
echo "$DATETIME Starting $PROGRAM (idle = $IDLE ms, trigger = $TRIGGER ms)"
screen -d -m -A -S program_title $PROGRAM_FULL_PATH $PROGRAM_OPTS
else
echo "$DATETIME Already started $PROGRAM (PID = $RUNNED_PID, idle = $IDLE ms, trigger = $TRIGGER ms)"
fi
else
if [ ! -z $RUNNED_PID ]; then
echo "$DATETIME Stopping $PROGRAM (PID = $RUNNED_PID, idle = $IDLE ms, trigger = $TRIGGER ms)"
killall $PROGRAM
else
echo "$DATETIME Already stopped $PROGRAM (idle = $IDLE ms, trigger = $TRIGGER ms)"
fi
fi