Auto update & upgrade your pi with MyController.

  • If you want to automate keeping your pi up-to-date then this little script may be for you.

    Just copy and save it in a file (I called mine - but you can use whatever name you like!) and then use crontab -e to run the above named file whenever you want.

    I tested it by daily running, but now it only runs once a week in the early hours of the morning.

    export DEBIAN_FRONTEND=noninteractive
    export DEBIAN_PRIORITY=critical
    sudo bash /home/mycontroller/bin/
    sleep 15
    sudo bash /home/mcagent/bin/
    sleep 15
    sudo -E apt-get -qy update
    sudo -E apt-get -qy -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" upgrade
    sudo -E apt-get -qy autoclean
    sudo reboot

    Maybe some of you might even have improvements to suggest! 😉

  • MOD


    Cool!! great work!! :thumbs_up:

    Think that the sleep can be replaced with a test if the script is still running. will have a look see what i can find.

  • Yeah, I thought about that but 'sleep' seems only to work with processes spawned within the script - or maybe I completely mis-understand it. I'm still learning a lot! 😉

  • MOD

    Well, looking at the start and stop scripts, there is a test that looks if mycontroller is running..

    ps -ef | grep "org.mycontroller.standalone.StartApp" | grep -v grep | awk '{ print $2 }'

    so you could test if the line above returns the pid of mycontroller. If a number (process id) is returned, mycontroller is running, if no data returned, mycontroller is down..

  • @Tag

    That's brilliant - Thank you!

    McAgent is similar, so could work for both.....

    I have to take Mum shopping today but will try this out in the script as soon as I can 😉

Suggested Topics