0

I wrote a script to scrape my motherboard manufacturers website and check if a newer version of BIOS is available. It should execute 5 Minutes after reboot, but for some reason does not appear to be working. Here is my python script.

#!/usr/bin/python3
import os
import sys

from bs4 import BeautifulSoup
import requests

def check_bios():
    CURRENT_BIOS = 'F63a'

    url="https://www.gigabyte.com/Motherboard/B450-AORUS-PRO-WIFI-rev-1x/support#support-dl-bios"


    # Make a GET request to fetch the raw HTML content
    resp = requests.get(url)

    if resp.status_code != 200:
        os.system(f"notify-send 'BIOS CHECK FAIL' '{url} appears to be down'")

    html_content = resp.text
    soup = BeautifulSoup(html_content, "lxml")
    mydivs = soup.find_all("div", class_="div-table-cell download-version")
    for tag in mydivs:
        if 'F' in tag.text:
            if tag.text.strip() > CURRENT_BIOS:
                print(tag.text.strip())
                os.system(f"notify-send 'NEW BIOS AVAILABLE' 'You are currently on version {CURRENT_BIOS}\n, but {tag.text.strip()} is available'")


if __name__=='__main__':
    check_bios()

Here is the entry in crontab:

@reboot sleep 300 && /usr/local/bin/check_bios.py

These are the permissions on the file:

-rwxr-xr-x 1 root root 913 Apr 20 19:23 /usr/local/bin/check_bios.py

Here is the output of grep CRON /var/log/syslog:

Aug  8 07:23:01 Custom CRON[739]: (CRON) info (No MTA installed, discarding output)
Aug  8 07:30:01 Custom CRON[6335]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 08:17:01 Custom CRON[11961]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 08:30:01 Custom CRON[12837]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 09:17:01 Custom CRON[18564]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 09:30:01 Custom CRON[20970]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 10:17:01 Custom CRON[23061]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 10:30:01 Custom CRON[24084]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 11:17:01 Custom CRON[24784]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 11:30:01 Custom CRON[25704]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 12:17:01 Custom CRON[29501]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 12:30:01 Custom CRON[30510]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 13:17:01 Custom CRON[35734]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 13:30:01 Custom CRON[36650]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 14:17:01 Custom CRON[37384]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 14:30:01 Custom CRON[38141]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 15:17:01 Custom CRON[43619]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 15:30:01 Custom CRON[44489]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)
Aug  8 16:17:01 Custom CRON[50643]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  8 16:30:01 Custom CRON[51305]: (root) CMD ([ -x /etc/init.d/anacron ] && if [ ! -d /run/systemd/system ]; then /usr/sbin/invoke-rc.d anacron start >/dev/null; fi)

When I execute the script manually with:

/usr/local/bin/check_bios.py

It works just fine and gives me the pop-up message that a new BIOS version is available. I can't figure out why it won't fire automatically 5 minutes after reboot. Feel like I'm missing something obvious. Any advice/trouble shooting tips are greatly appreciated.

Michael
  • 749
  • 1
  • 8
  • 22
  • The operative term is here **gives me the pop-up message** ... the cron environment doesn't know anything about your DE/WM ... check roots mail (or add a redirect of output for the script for details). – tink Aug 08 '22 at 22:01
  • Thank you for the response. I'm not exactly sure what you mean. I thought cron just executed the script and because it works when I execute it manually it would work as a cron job. (Googling DE/WM now) – Michael Aug 08 '22 at 22:04
  • Does [this](https://stackoverflow.com/a/68933388/1394729) help? – tink Aug 08 '22 at 22:04
  • Or [this](https://stackoverflow.com/questions/71026008/cron-task-which-displays-something-task-launched-but-nothing-happens) – tink Aug 08 '22 at 22:12
  • 1
    Still reading through the first one @tink. DEFINITELY helps. Thank you VERY much. Got some reading/learning to do. Thanks again! – Michael Aug 08 '22 at 22:49

0 Answers0