Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-18507

some command can't exit in the execute windows batch command (praqma case 9630)

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • durable-task-plugin
    • None

      My jenkins version is ver. 1.493 .
      the command can run in cmd model and can normally end. you can see the log1 below.
      But I put the command into the execute windows batch command, and then I run the job,the job hold on and can't end wait for long times. You can see the log2 below. I manually execute the bat file "C:\Users\Admin\AppData\Local\Temp\hudson9214056810875413252.bat" in cmd model . it can end.

      – log1
      C:\Users\Admin>PSEXEC -accepteula -s
      GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" |findstr "Disabled"

      PsExec v1.98 - Execute processes remotely
      Copyright (C) 2001-2010 Mark Russinovich
      Sysinternals - www.sysinternals.com

      Starting SCHTASKS on GPS68 ...GPS68 ...
      SCHTASKS exited on GPS68 with error code 0.
      SDT Disabled

      --log2
      [workspace] $ cmd /c call C:\Users\Admin\AppData\Local\Temp\hudson9214056810875413252.bat

      D:\Jenkins\jobs\tsd_test\workspace>PSEXEC -accepteula
      GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" | findstr "Disabled"

      PsExec v1.98 - Execute processes remotely
      Copyright (C) 2001-2010 Mark Russinovich
      Sysinternals - www.sysinternals.com

        1. buildlog.jpg
          buildlog.jpg
          22 kB
        2. buildred.jpg
          buildred.jpg
          7 kB
        3. hudson6148162320693807782.bat
          0.1 kB
        4. jenkinsbuildlog.txt
          0.5 kB
        5. log.txt
          0.0 kB

          [JENKINS-18507] some command can't exit in the execute windows batch command (praqma case 9630)

          Jens Brejner added a comment -

          Hi dzy dzy.

          I do not think there is any bug in this, but either PSEXEC or SCHTASK is waiting for some input

          Is the jenkins job / service running with your credentials or does it run as LocalSystem ?

          I am also wondering if your job is the actual job or are you testing PSEXEC ?
          If it the real job, and you want you jenkins, to check - on a remote machine - if the remote machine's scheduled task named SDT is disabled, I would suggest 2 different approaches to you:
          A) Install a jenkins slave on the remote machine, and create a job tied to that slave, the job shall then do what you wanted to do in the scheduled task
          or
          B) use schtasks with it's /S parameter:

          Parameter List:
          /S system Specifies the remote system to connect to.

          /U username Specifies the user context under
          which schtasks.exe should execute.

          /P [password] Specifies the password for the given
          user context. Prompts for input if omitted.

          Jens Brejner added a comment - Hi dzy dzy. I do not think there is any bug in this, but either PSEXEC or SCHTASK is waiting for some input Is the jenkins job / service running with your credentials or does it run as LocalSystem ? I am also wondering if your job is the actual job or are you testing PSEXEC ? If it the real job, and you want you jenkins, to check - on a remote machine - if the remote machine's scheduled task named SDT is disabled, I would suggest 2 different approaches to you: A) Install a jenkins slave on the remote machine, and create a job tied to that slave, the job shall then do what you wanted to do in the scheduled task or B) use schtasks with it's /S parameter: Parameter List: /S system Specifies the remote system to connect to. /U username Specifies the user context under which schtasks.exe should execute. /P [password] Specifies the password for the given user context. Prompts for input if omitted.

          dzy dzy added a comment -

          hi Jens,
          but either PSEXEC or SCHTASK is waiting for some input.

          there is no inputs.

          the Jenkins is installed at server cibuilder and use the account builder to run tomcat with Jenkins. I used the account builder to login into the cibuilder server and use command "PSEXEC -accepteula
          GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" | findstr "Disabled" " in cmd model . the command can end. at the same time i execute the bat which is generated by Jenkins . the bat file can execute normally .

          but the jobs can't end with command "PSEXEC -accepteula
          GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" | findstr "Disabled" " in the execute windows batch command.

          Can you test ? the command and bat file can end normally .but the job can't using the same server and same account .

          I used Jenkins to deploy C# code with more than 20 servers. It is impossible to install slave at every servers.

          dzy dzy added a comment - hi Jens, but either PSEXEC or SCHTASK is waiting for some input. there is no inputs. the Jenkins is installed at server cibuilder and use the account builder to run tomcat with Jenkins. I used the account builder to login into the cibuilder server and use command "PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" | findstr "Disabled" " in cmd model . the command can end. at the same time i execute the bat which is generated by Jenkins . the bat file can execute normally . but the jobs can't end with command "PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" | findstr "Disabled" " in the execute windows batch command. Can you test ? the command and bat file can end normally .but the job can't using the same server and same account . I used Jenkins to deploy C# code with more than 20 servers. It is impossible to install slave at every servers.

          dzy dzy added a comment -

          In addition the schtasks \GOPP\SDT is disable at server GPS68 . when I run the job to disable the schtask,it cannot stop ,but it can end normally in cmd model.

          dzy dzy added a comment - In addition the schtasks \GOPP\SDT is disable at server GPS68 . when I run the job to disable the schtask,it cannot stop ,but it can end normally in cmd model.

          dzy dzy added a comment -

          when the schtasks is able, and than run the job to disable the schtasks, the job can stop normally.

          dzy dzy added a comment - when the schtasks is able, and than run the job to disable the schtasks, the job can stop normally.

          Jens Brejner added a comment -

          try to break it into multiple commands:

          PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" 2>&1 > "%TEMP%\FILE.TXT"
          findstr "Disabled" "%TEMP%\FILE.TXT"
          echo.
          ehco Here comes file contents:
          type "%TEMP%\FILE.TXT"

          Jens Brejner added a comment - try to break it into multiple commands: PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" 2>&1 > "%TEMP%\FILE.TXT" findstr "Disabled" "%TEMP%\FILE.TXT" echo. ehco Here comes file contents: type "%TEMP%\FILE.TXT"

          dzy dzy added a comment -

          Hi Jens:
          The error is the same as the old.

          If the schtasks is disable and I run the job with command "PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" 2>&1 > "%TEMP%\FILE.TXT"" to disable the schtask. the Job hold on and can't stop normally, But I executed the command with cmd model. it can stop normally.

          I can't find the root cause, but it affects the deployment. the job can't stop.

          dzy dzy added a comment - Hi Jens: The error is the same as the old. If the schtasks is disable and I run the job with command "PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GOPP\SDT" 2>&1 > "%TEMP%\FILE.TXT"" to disable the schtask. the Job hold on and can't stop normally, But I executed the command with cmd model. it can stop normally. I can't find the root cause, but it affects the deployment. the job can't stop.

          dzy dzy added a comment -

          After executed sometimes, the build progress bar was red in build history.

          dzy dzy added a comment - After executed sometimes, the build progress bar was red in build history.

          Jens Brejner added a comment -

          Can you send me the job log ?
          And or contents of "%TEMP%\FILE.TXT"

          Jens Brejner added a comment - Can you send me the job log ? And or contents of "%TEMP%\FILE.TXT"

          dzy dzy added a comment -

          Hi Jens:
          I added the attachment, Please look.

          The log is generated by executing the command "PSEXEC -accepteula
          GPS68 SCHTASKS /QUERY /TN "\GPP\SDT" 2>&1 >> d:\log.txt".

          When i executed the command in cmd model, you can see the log below.

          Microsoft Windows [Version 6.1.7601]
          Copyright (c) 2009 Microsoft Corporation. All rights reserved.

          C:\Users\Admin>PSEXEC -accepteula
          GPS68 SCHTASKS /QUERY /TN "\GPP\SDT"

          PsExec v1.98 - Execute processes remotely
          Copyright (C) 2001-2010 Mark Russinovich
          Sysinternals - www.sysinternals.com

          Folder: \GPP
          TaskName Next Run Time Status
          ======================================== ====================== ===============
          SDT 7/4/2013 1:00:40 AM Ready
          SCHTASKS exited on GPS68 with error code 0.

          C:\Users\Admin>

          dzy dzy added a comment - Hi Jens: I added the attachment, Please look. The log is generated by executing the command "PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GPP\SDT" 2>&1 >> d:\log.txt". When i executed the command in cmd model, you can see the log below. Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\Admin>PSEXEC -accepteula GPS68 SCHTASKS /QUERY /TN "\GPP\SDT" PsExec v1.98 - Execute processes remotely Copyright (C) 2001-2010 Mark Russinovich Sysinternals - www.sysinternals.com Folder: \GPP TaskName Next Run Time Status ======================================== ====================== =============== SDT 7/4/2013 1:00:40 AM Ready SCHTASKS exited on GPS68 with error code 0. C:\Users\Admin>

          dzy dzy added a comment -

          when it taked 30minutes,the job can't stop so i canceld, you can see "Build was aborted" ,but it taked less than 3 seconds in cmd model.

          dzy dzy added a comment - when it taked 30minutes,the job can't stop so i canceld, you can see "Build was aborted" ,but it taked less than 3 seconds in cmd model.

            Unassigned Unassigned
            dzyjl dzy dzy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: