Recommend having run-agent.sh force itself into the right directory... #12

Closed
nklein opened this Issue Jan 27, 2013 · 5 comments

Projects

None yet

2 participants

@nklein
Contributor
nklein commented Jan 27, 2013

I was trying to set up a cron-job to run this script but found I was going to have to make a wrapper script to run from cron or do something else similar because run-agent.sh assumes you're going to run it from the right directory.

I added one line to the beginning of the script that I think should be in the run-agent.sh.sample file:

cd "`dirname $0`"

... Patrick

@avodonosov
Contributor

Thanks.

My crontab record is the following (as also show in the agent documentation):

# m h  dom mon dow   command
0 10 * * * cd /home/testgrid/cl-test-grid2/ && ./run-agent.sh

I will consider adding to to run-agent.sh. It would be good then to return to the original directory.

@avodonosov avodonosov added a commit that closed this issue Jan 27, 2013
@avodonosov avodonosov close #12 - run-agent.sh.sample ensures the current directory is the …
…one where run-agent.sh is located. Thanks to Patrick Stein.
29cae9a
@avodonosov
Contributor

Ah, I forgot the shell script is executed by separate subprocess, so cd doesn't affect the parent.
Added this command, thanks.

@nklein
Contributor
nklein commented Jan 27, 2013

And, I wanted to run it from root's crontab with an su to user cltestgrid and my attempt to do:

su - cltestgrid sh -c "( cd /Users/cltestgrid/cl-test-grid ; ./run-agent.lisp )"

was mad for some reason.

I wanted to do it from root's crontab because I am already used to getting crontab emails from root. I suppose I could/should use a .forward instead... shrug

-- Patrick pat@nklein.com

On Jan 27, 2013, at 12:31 PM, Anton Vodonosov notifications@github.com wrote:

Thanks.

My crontab record is the following (as also show in the agent documentation):

m h dom mon dow command

0 10 * * * cd /home/testgrid/cl-test-grid2/ && ./run-agent.sh
I will consider adding to to run-agent.sh. It would be good then to return to the original directory.


Reply to this email directly or view it on GitHub.

@nklein
Contributor
nklein commented Jan 27, 2013

(In Unix) Once the script exits you will be back to the directory in which you ran the script. The line I suggested would only affect things for the duration of the script.

If I am in /tmp and run /Users/cltestgrid/cl-test-grid/run-agent.sh, then the attempt to update with git immediately fails because I am not in the right directory. With my addition, the script switches to that directory but the shell I ran it from is unaffected.

-- Patrick pat@nklein.com

On Jan 27, 2013, at 12:31 PM, Anton Vodonosov notifications@github.com wrote:

I will consider adding to to run-agent.sh. It would be good then to return to the original directory.

@nklein
Contributor
nklein commented Jan 27, 2013

I should have read the whole way to the end. Yep. :)

-- Patrick pat@nklein.com

On Jan 27, 2013, at 12:39 PM, Anton Vodonosov notifications@github.com wrote:

Ah, I forgot the shell script is executed by separate subprocess, so cd doesn't affect the parent.
Added this command, thanks.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment