Git commands inside a batch file won't run under a scheduled task when no user is logged onto the server.

Christian Palacios
Christian Palacios used Ask the Experts™
on
I have a scheduled task that runs a batch file.  The batch file has several lines where I do a "git pull" command from a specific Git repository.  The Windows server where this runs has already been configured with proxy settings so that when you run "git pull" or any "git" command, it will properly connect to the required repository and run the command.  I have figured out that this schedule task and batch file will run just fine when a user is logged on.  But if I log out of the server, the schedule task start, but the "git pull" command gets stuck.  It's almost like it's can't connect and then the rest of the batch file will not run.  What should I do to ensure the "git" commands run fine even when a user is not logged in?

Thanks in advance!
-Christian
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
When using that option you need to use also the "Run with highest privileges" option.

Also if your batch uses network shares , when not logged in it doesnt know which drives are mapped so it will fail.
Also check the user setup for running the task has all the proper permissions for any shares or internet access it might need.
Christian PalaciosSenior IT Systems Administrator

Author

Commented:
Thanks Arana.  The scheduled task has "Run with highest privileges" enabled.  It's configured for Windows Server 2012 R2.  I am running this scheduled task with a service account, which by default, does not have a proxy account to go to the internet.  Here's what I do for each Git repository when I am doing a pull:

cd "C:\SDS_IT\OneGeo\configuration-manager"
git pull


Anything else I should try?
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

try running it under an account that has proxy permissions, you can create one just for this purpose,
or try running
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:port

Open in new window

Christian PalaciosSenior IT Systems Administrator

Author

Commented:
Thanks Arana.  I have configured git with my proxy settings with the command you sent me.  I'll try it out and let you know.
Christian PalaciosSenior IT Systems Administrator

Author

Commented:
Ok, that didn't work.  I made sure I could do a pull before I logged out after I set the global proxy settings.  I logged in to check it and it's still stuck at the first "git pull" command.  This is the command I ran:

git config --global http.proxy http://username:password@proxyIP:80

Anything else I could try?
hmm I would try to use an account other than that service (your for example) for running when not logged in, just to test if that is the issue then setup the actual account you will use in the proxy.
Christian PalaciosSenior IT Systems Administrator

Author

Commented:
Just tried it by setting the scheduled task to run under my domain account.  I logged into the VM with my account and tested everything to ensure I was able to run every manually and everything worked.  I even ran the code I need to test with Visual Studio.  It still needs me to be logged into the VM before it'll do the "git" command.  Anything else I should try?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial