How can I open a shell in the environment that cron (alternatively launchd) uses to execute commands?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I am trying to get launchd (which is macOS's alternative for cron) to run a job for me. It doesn't work, while running the commands on a bash launched with sudo does. I tried redirecting the output to files, but examining them hasn't enlightened me, either. I like to have access to this 'primal' environment launchd uses to execute commands, so that I can experiment directly there and see what is missing.



PS: Here is the script I run in my launchd job (as root):



#!/usr/bin/env bash
export HOME=/Users/evar
source /users/evar/.bashrc
/Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup &> /Users/evar/log/hosts.out2
# tmux new -d -s hosts "/Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup" # I tried this, but sudo tmux kept saying no sessions while logs kept said "duplicate session hosts".









share|improve this question

























    up vote
    0
    down vote

    favorite












    I am trying to get launchd (which is macOS's alternative for cron) to run a job for me. It doesn't work, while running the commands on a bash launched with sudo does. I tried redirecting the output to files, but examining them hasn't enlightened me, either. I like to have access to this 'primal' environment launchd uses to execute commands, so that I can experiment directly there and see what is missing.



    PS: Here is the script I run in my launchd job (as root):



    #!/usr/bin/env bash
    export HOME=/Users/evar
    source /users/evar/.bashrc
    /Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup &> /Users/evar/log/hosts.out2
    # tmux new -d -s hosts "/Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup" # I tried this, but sudo tmux kept saying no sessions while logs kept said "duplicate session hosts".









    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am trying to get launchd (which is macOS's alternative for cron) to run a job for me. It doesn't work, while running the commands on a bash launched with sudo does. I tried redirecting the output to files, but examining them hasn't enlightened me, either. I like to have access to this 'primal' environment launchd uses to execute commands, so that I can experiment directly there and see what is missing.



      PS: Here is the script I run in my launchd job (as root):



      #!/usr/bin/env bash
      export HOME=/Users/evar
      source /users/evar/.bashrc
      /Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup &> /Users/evar/log/hosts.out2
      # tmux new -d -s hosts "/Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup" # I tried this, but sudo tmux kept saying no sessions while logs kept said "duplicate session hosts".









      share|improve this question













      I am trying to get launchd (which is macOS's alternative for cron) to run a job for me. It doesn't work, while running the commands on a bash launched with sudo does. I tried redirecting the output to files, but examining them hasn't enlightened me, either. I like to have access to this 'primal' environment launchd uses to execute commands, so that I can experiment directly there and see what is missing.



      PS: Here is the script I run in my launchd job (as root):



      #!/usr/bin/env bash
      export HOME=/Users/evar
      source /users/evar/.bashrc
      /Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup &> /Users/evar/log/hosts.out2
      # tmux new -d -s hosts "/Users/evar/anaconda/bin/python /Base/_Code/Misc/hosts/updateHostsFile.py --auto --replace --backup" # I tried this, but sudo tmux kept saying no sessions while logs kept said "duplicate session hosts".






      bash shell sudo cron anaconda






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 25 mins ago









      HappyFace

      22710




      22710

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478718%2fhow-can-i-open-a-shell-in-the-environment-that-cron-alternatively-launchd-uses%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478718%2fhow-can-i-open-a-shell-in-the-environment-that-cron-alternatively-launchd-uses%23new-answer', 'question_page');

          );

          Post as a guest