linuxbashubuntucrongksudo

How to set the working directory using gksu gnome-schedule


How do I set the working directory using gksu gnome-schedule so that all shells referenced in my script use the working directory I set using cd?

On Ubuntu I have a shell script called runProcess.sh. The script is located in a directory called /var/myscripts. The script needs to execute from the /var/myscripts directory as the script references other shells in the same directory or within subdirectories of /var/myscripts. The script also needs to run as root.

The script runs just fine when running manually. However, when I set it to run using gksu gnome-schedule the script fails as it doesn't seem to use the working directory when running the shells I call within the runProcess.sh

Here is how I set to run the script in gksu gnome-schedule

cd /var/myscripts && ./runProcess.sh

Here is an example of the script called.

#!/bin/bash

. functions.sh

. loadSecrets

. startProcess.sh 

. checkOnProgress.sh

. cleanUp.sh 

Solution

  • Default directory is refer to $HOME and you can change your terminal default directory for any user with usermod command :

    usermod -m -d /your/path/to/directory username