Menu

Mutitple commands in exec for Linux

General
2015-08-26
2015-09-19
  • Ryan Sheftel

    Ryan Sheftel - 2015-08-26

    I am using oddjob with Linux (Mint 17.1 to be exact) and have the following situation:

    • I want to run a python script using the exec job.
    • My python command requires the PYTHONPATH environment variable to be set.
    • I have a standard script (setup.sh) that I auto load (via .bashrc) whenver the bash shell starts that sets up my environment, so that invoking the python script from a standard linux bash works.

    When I tried to just put the python script in the exec command ("python runme.py") it fails because the PYTHONPATH is not set. This makes me believe that the exec command does not invoke the .bashrc or .bash_profile scripts when it runs.

    When I ran into this problem using cron I could solve it by using the && operator to put multiple commands in one line like the following:

    source setup.sh && python runme.py

    When I do this in oddjob with the exec command it says that "source" is a command not found. So then I try the following:

    setup.sh && python runme.py

    This seems to only run the first command, setup.sh, and ignore the rest of the line. I tried with the ";" operator and it did the same thing.

    Any advice on the right way to put multiple commands into one exec job? Or is the right answer to run each command in a seperate exec, but then do they share a console?

    Help appreciated. Thanks.

     
  • Rob Gordon

    Rob Gordon - 2015-09-01

    Hi - does running a shell from Oddjob work? i.e. bash -c "setup.sh && python runme.py"
    Rob.

     
  • Ryan Sheftel

    Ryan Sheftel - 2015-09-19

    That works. Perfect, thanks.

     

Log in to post a comment.