Announcement

Collapse
No announcement yet.

autostart login scripts run, but the programs they call never run

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [RESOLVED] autostart login scripts run, but the programs they call never run

    This is an upgrade from 20.04. Login scripts used to work in the previous version. I've had this problem since the upgrade, but wasn't bothered enough by it to ask for help, until now.

    I've created a script that runs a virtualbox VM headless. It is one of two scripts that run self-hosted cloud, and Home Assistant. If I add
    Code:
    echo "Script did run" > ~/scriptcheck.txt
    as the last line, the file is created, and written to. Scripts are located in ~/Custom, and they are marked as executable. They also work as intended if I double-click them, or run them from a terminal. I've started turning off the PC at night, and start it up just before leaving for work, so making these work is a high priority for me so I can have these important items running when I need them. Any help would be greatly appreciated.

    Here is the script:
    Code:
    #!/bin/bash
    vboxmanage startvm "Nextcloud-AIO" --type headless
    echo "Script does run" > /home/plex/scriptcheck.txt
    
    ​

    #2
    Firstly I suggest you change the echo to something like
    Code:
    date +"script $0 run at %F:%T.%3N" >>  ~/scriptcheck.txt
    ​
    The usual reason for "runs from a konsole, but not automatically" are environment variables. KDE autostart scripts are not so bad as cron jobs (which get nearly nothing set up) but you might know something virtualbox needs. I suggest getting your script to write out the environment somewhere, so that you can compare it run with autostart and from a konsole.

    A method I use to diagnose script problems is to put at the top of the script
    Code:
    log=/tmp/script.log
    
    code]
    date +"script $0 run at %F:%T.%3N" >>​ $log
    (
    then at the bottom
    Code:
    ) |& tee -a $log
    so error messages from the commands in the script get written to the log file.
    Regards, John Little

    Comment


      #3
      I added your code, and it looks like the login script is trying to run before the kernel driver loads. Since the script works fine when I launch it myself (after login) that is the only answer that I can come up with. Is there a way to delay the commands in the script for something like a minute, to see if that resolves it? The results below usually happen if the kernel driver needs reinstalling, or isn't yet loaded. In this case, it's just not loaded by the time the script runs.


      Code:
      script /home/plex/Custom/nextcloud.sh run at 2024-08-29:17:43:07.616
      WARNING: The vboxdrv kernel module is not loaded. Either there is no module
      available for the current kernel (6.8.0-40-generic) or it failed to
      load. Please recompile the kernel module and install it by
      
      sudo /sbin/vboxconfig
      
      You will not be able to start VMs until this problem is fixed.
      VBoxManage: error: The virtual machine 'Nextcloud-AIO' has terminated unexpectedly during startup with exit code 1 (0x1)
      VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
      Waiting for VM "Nextcloud-AIO" to power on...​
      Edit: So I did a little extra research and found that I can use systemd to automatically launch desired VMs on boot. This method has been tested, and works beautifully. The method I found is at this link. Thanks for the help!
      Last edited by jasoncollege24; Aug 29, 2024, 04:16 PM.

      Comment

      Working...
      X