Hacker News new | ask | show | jobs
by rovr138 1988 days ago
I've done things similar and do it for quick and dirty. Currently I have something like that on a RPi but instead of

    while true;
I have,

    while [[ ! -f "$DIRECTORY"/backup_exit.stop ]]; do
        sleep 3600 # sleep an hour
        time /home/ubuntu/.pyenv/versions/backup/bin/python main.py
    done
Whenever I want the process to stop, `touch backup_exit.stop` . This waits until the run finishes and exists on the next loop.

Anyway, that is saved to a 'backup.sh'

Then I have also,

    #!/bin/bash
    session="test"
    backup="/path/to/backup.sh" 
    
    #create detached session named test
    tmux new-session -d -s ${session}
    # Create windows
    tmux rename-window -t :0 'backup' #rename the first one
    tmux new-window -n 'htop'
    # Run processes
    tmux send-keys -t 'backup' "$backup" ENTER
    tmux send-keys -t 'htop' 'htop' ENTER
    
    
And this is run automatically on @reboot via cron.