0

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 
user1654528
  • 395
  • 3
  • 12

1 Answers1

0

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
Frd
  • 36
  • 7
  • Thanks. I have other cron scripts that run from other locations. If I change the working directory will it change for all those other scripts cron jobs? IS there a way to do that just for my script above? – user1654528 Dec 15 '15 at 09:25
  • Yes,`usermod -m -d` change default directory for Exist user and if you have to run some other scripts this make new problem. :) – Frd Dec 15 '15 at 10:03