making cron get the real username for a ssh only client

Discussion in 'Tips/Tricks/Mods' started by pannet1, Jul 23, 2025.

Tags:
  1. pannet1

    pannet1 Member

    Apologies if i am not posting in the correct forum/thread.

    i want to run a common shell script for all my python ssh clients, from cron. it looks like the below roughly

    Code:
    #!/bin/env bash
    ACTUAL_HOME="$HOME/home/<real_username>"
    
    export PATH="$ACTUAL_HOME/.local/bin:$PATH"
    export PYTHONPATH="$ACTUAL_HOME/.local/lib/python3.11/site-packages"
    
    PROJECT="$ACTUAL_HOME/no_venv/my_python_project"
    
    sess="tmux-session"
    if tmux has-session -t "$sess" 2>/dev/null; then
      echo "[$(date)] Session '$sess' already running. Skipping start."
      exit 0
    fi
    
    cd "$PROJECT" || exit 1
    tmux new-session -d -s "$sess"
    tmux send-keys -t "$sess" "python3 -m src.main && tmux kill-session -t $sess" C-m
    it runs perfectly fine. the only problem is i need to hardcode the
    for all the clients. i even tried to set the variable from outside the cron.sh, so it is just a matter of letting cron read it, but i failed. is there a way, i can make a variable via ispconfig-> cron jobs -> commands to run -> variables. if not what is the alternative.
     

Share This Page