Scheduled Task running script failing Windows 10

Advertisement

ThisMayHelpSomeone
Guest

Scheduled Task running script failing Windows 10

Hello there,

I've just been getting stuck trying to Schedule a Task running WinSCP - a pretty simple task that SFTPs a directory from a server and downloads it all to a backup drive locally.
It repeatedly failed with a black WinSCP window (if running /console) or the process just hanging (without /console), seemingly doing nothing. The logs showed reported it was getting stuck just after reporting its Process ID into the log. I could verify this and see the process sitting there consuming CPU but not any network traffic.

I tried several different steps to resolve, but ultimately what fixed it was changing the command line option for logging from /log to /logxml - I only found this because I was trying to find more details in the log to determine the issue.
Presumably a bug? I thought I would submit this here for your info.

Details follow:
-------------
I could run the script from command prompt successfully, here's the command:
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /console /log="C:\Users\username\WinSCP-backup-script.log" /ini=nul /script="C:\Users\username\WinSCP-backup-script.script"
Script contents:
open sftp://user@000.111.222.333/ -hostkey="ssh-ed25519 255 [alphanumeric-code]" -privatekey="C:\Users\user\SSHKeys\ssh-private-key.ppk"
 
cd /home/data/backup
lcd H:\!SFTP_Backups
 
get -speed=2048 -neweronly *
 
exit
 
# Execute the script using a command like:
# "C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="C:\writable\path\to\log\WinSCP.log" /ini=nul /script="C:\path\to\script\script.txt" 
 

The Scheduled Task (where the problem began) was set to run as my user account, while logged in, following all the usual settings in the guide. Here's my command-line options:
/log="C:\Users\username\WinSCP-backup-script.xml" /ini=nul /script="C:\Users\username\WinSCP-backup-script.script"
* NB: this command-line option is what I changed to /xmllog= and it suddenly began working. Same log folder/permissions, nothing else changed.

Here's a sample of the log entries (before changing over to xml):
. 2021-07-07 21:29:37.828 --------------------------------------------------------------------------
. 2021-07-07 21:29:37.828 WinSCP Version 5.19.1 (Build 11552) (OS 10.0.19041 - Windows 10 Enterprise)
. 2021-07-07 21:29:37.828 Configuration: nul
. 2021-07-07 21:29:37.829 Log level: Normal
. 2021-07-07 21:29:37.829 Local account: COMPUTERNAME\username
. 2021-07-07 21:29:37.829 Working directory: C:\Users\username
. 2021-07-07 21:29:37.829 Process ID: 28360
(then it ends - and repeats for the next log session).

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,378
Location:
Prague, Czechia

Re: Scheduled Task running script failing Windows 10 - solution

Thanks for your report.

Can you send me an email, so I can send you back a debug version of WinSCP to track the problem? Please include a link back to this topic in your email. Also note in this topic that you have sent the email. Thanks.

You will find my address (if you log in) in my forum profile.

Reply with quote

Kenlek
Joined:
Posts:
2
Location:
norway

Same problem..... same temp fix.

Hi!

I wanted to add that the exact same type of problem happened to 2 different solutions that only have WinSCP in common. And both got a sudden CPU usage problem after they were upgraded to 5.19.1.

I stumbled over the fix when I tried to mitigate the fact that some of the log files were getting very large. So my first attempt was just to remove those to the "archive folder". And start again, but that did not help. But when I tested changing the log format to XML it suddenly was working as intended again. All FTP traffic now goes as it should, and I see no more "CPU hooks" on the server by WinSCP.exe processes.

No need to add more info, since the situation is exactly the same as described in this Thread.
I can live with having XML format on log files, but would probably be valuable information to you regardless.

Regards Kenneth

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Same problem..... same temp fix.

@Kenlek: Thanks for your report. I'm also sending you the debug build.

Please respond. So far, everyone is posting "me too". But until some finally help me resolving this, it won't get fixed. No one responded me so far.

Reply with quote

Kenlek
Joined:
Posts:
2
Location:
norway

Status

Hi! I understand fully. It is difficult to do any form of bug testing without info from failing environment. But unfortunately both these 2 solutions are now working with XML as log format. And the customers will not allow med to do anything with the solution since it is now working. And they have no problem with XML as log format.

I suggest, if possible to setup a somewhat similar test environment. The solution is rather straight forward. One of the Customers use Windows Server 2016, and the other are using Windows Server 2012 R2. What they have in common is that they run .bat script through Scheduled tasks (10 min interval). They ran about 12 such script, and normal runtime is just a few secs.
The WinSCP commands runs from a file that the .bat script calls for.

In practicality, it is the same solution that OP described.

Sorry that I cannot be more helpful. If I run into the problem again I will make sure to try and include such a debug process as part of the work we do.

Regards Kenneth!

Reply with quote

martin
Site Admin
martin avatar

Re: Status

@Kenlek Thanks. Can you (or anyone else involved here) share details of the scheduled task? What are the security options? Run only when user is logged on, Run whether user is logged on or not, Run with highest privileges? What user? A regular one or some system account?

Reply with quote

vinylfish
Guest

Re: Status

I am new but am also getting this error. My task scheduler settings are
Run whether user is logged in or not and Run with Highest Privileges. My user is a system administration account and this process has been running for a year with no issues until last week.

The replacing log with xmllog temporary fix also worked for me.
. 2021-07-19 16:11:19.591 WinSCP Version 5.19.1 (Build 11552) (OS 10.0.17763 - Windows Server 2019 Standard)
. 2021-07-19 16:11:19.591 Configuration: nul
. 2021-07-19 16:11:19.591 Log level: Debug 2
. 2021-07-19 16:11:19.591 Local account: hostname\user
. 2021-07-19 16:11:19.591 Working directory: C:\Windows\system32
. 2021-07-19 16:11:19.591 Process ID: 8952

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum