To create a user timer that triggers the weather script every hour, you need to create a user-specific systemd service and timer. Here are the steps:

  1. Place the Weather Script: Ensure the weather script is in a location accessible by the user. For this example, we’ll place it in ~/bin/log_weather.sh.

    mkdir -p ~/bin
    cp /usr/local/bin/log_weather.sh ~/bin/log_weather.sh
    chmod +x ~/bin/log_weather.sh
    
  2. Create a User Systemd Service: Create a systemd service file in the user’s systemd configuration directory.

    mkdir -p ~/.config/systemd/user
    

    Create a file named log_weather.service in ~/.config/systemd/user with the following content:

    [Unit]
    Description=Log Weather Information
    
    [Service]
    Type=oneshot
    ExecStart=%h/bin/log_weather.sh
    
  3. Create a User Systemd Timer: Create a systemd timer file in the same directory.

    Create a file named log_weather.timer in ~/.config/systemd/user with the following content:

    [Unit]
    Description=Run Log Weather Script Every Hour
    
    [Timer]
    OnCalendar=hourly
    Persistent=true
    
    [Install]
    WantedBy=timers.target
    
  4. Enable and Start the Timer: Enable and start the timer for the user. Run the following commands in the user’s shell:

    systemctl --user daemon-reload
    systemctl --user enable log_weather.timer
    systemctl --user start log_weather.timer
    
  5. Verify the Timer: Check the status of the timer to ensure it is running:

    systemctl --user status log_weather.timer
    

This setup will ensure that your weather script runs every hour as a user-specific service. The weather information will be logged according to the logic specified in your script.