I am making some Scheduled Tasks for running SnapRAID nightly syncs.
The first issue is that the output log file is oddly organized... I am running the command: snapraid sync > "sync.log" 2>&1
This should redirect the output (with errors, stdout and stderr) to sync.log. It does, but all stderr messages appear at the bottom of the log instead of inline mixed with the stdout where they belong. I'm not sure if this is a Windows issue, my command line syntax, or something with SnapRAID, but I've never run into it before and I have used the same syntax on other programs. As an example, the final line of this particular log should be "Nothing to do", but instead underneath that it has all of the "WARNING! Ignoring special 'system-directory' file" entires. These warning messages are actually one of the first to appear, and I can't figure out why it's all the way on the bottom of the output log.
Sidenote: I spent countless hours trying to get some method of visibly outputting to both the console AND to a text file log and was unsuccessful despite finding about 5 different tools that are supposed to do it. This is supposedly easy in Linux but proved a nightmare in Windows. Once again I'm not sure if I was using the tools incorrectly or maybe SnapRAID just couldn't co-operate with them. Would it be feasible to add a built in logging option for SnapRAID, so that it can display the status on screen while writing to a log at the same time? There's already the option of writing a detailed log for fix operations, but not for anything else. Also using console output redirection in Windows does not allow the file to be read until the redirected process ends, so there's no way to check the running status. That would be another benefit of SnapRAID writing its own logfiles.
The second thing is about the snapraid result/exit codes... I have a second script that must ONLY be run if the sync is 100% successful with absolutely no failures or errors. Will SnapRAID set an exit code of 0 if the sync completes but with bypassable errors? For example in one instance I modified or deleted a file during the sync and SnapRAID warned me but continued the operation to completion. For a case like this (or similar), will I get an exit code of 0? If so, can this be changed? It is absolutely essential that the second script only run when the parity is fully synced. If I can't rely on exit codes for that, I'll have to parse the output log.
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm going to improve the log system in the new 8.0 version of SnapRAID.
In that version, you'll be able to get a complete log in all commands.
About the return code. Yes. If there is any kind of error, the exit code is different than 0. Even in the case that errors are handled someway, like in case of silent errors.
Ciao,
Andrea
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hopefully, snapraid scrub can gain a "quiet" switch so that when running from cron, it would not print out the percentage counter. Thanks in advance :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am making some Scheduled Tasks for running SnapRAID nightly syncs.
The first issue is that the output log file is oddly organized... I am running the command: snapraid sync > "sync.log" 2>&1
This should redirect the output (with errors, stdout and stderr) to sync.log. It does, but all stderr messages appear at the bottom of the log instead of inline mixed with the stdout where they belong. I'm not sure if this is a Windows issue, my command line syntax, or something with SnapRAID, but I've never run into it before and I have used the same syntax on other programs. As an example, the final line of this particular log should be "Nothing to do", but instead underneath that it has all of the "WARNING! Ignoring special 'system-directory' file" entires. These warning messages are actually one of the first to appear, and I can't figure out why it's all the way on the bottom of the output log.
Sidenote: I spent countless hours trying to get some method of visibly outputting to both the console AND to a text file log and was unsuccessful despite finding about 5 different tools that are supposed to do it. This is supposedly easy in Linux but proved a nightmare in Windows. Once again I'm not sure if I was using the tools incorrectly or maybe SnapRAID just couldn't co-operate with them. Would it be feasible to add a built in logging option for SnapRAID, so that it can display the status on screen while writing to a log at the same time? There's already the option of writing a detailed log for fix operations, but not for anything else. Also using console output redirection in Windows does not allow the file to be read until the redirected process ends, so there's no way to check the running status. That would be another benefit of SnapRAID writing its own logfiles.
The second thing is about the snapraid result/exit codes... I have a second script that must ONLY be run if the sync is 100% successful with absolutely no failures or errors. Will SnapRAID set an exit code of 0 if the sync completes but with bypassable errors? For example in one instance I modified or deleted a file during the sync and SnapRAID warned me but continued the operation to completion. For a case like this (or similar), will I get an exit code of 0? If so, can this be changed? It is absolutely essential that the second script only run when the parity is fully synced. If I can't rely on exit codes for that, I'll have to parse the output log.
Thanks!
Hi Quaraxkad,
I'm going to improve the log system in the new 8.0 version of SnapRAID.
In that version, you'll be able to get a complete log in all commands.
About the return code. Yes. If there is any kind of error, the exit code is different than 0. Even in the case that errors are handled someway, like in case of silent errors.
Ciao,
Andrea
Excellent, thank you!
Hopefully,
snapraid scrubcan gain a "quiet" switch so that when running from cron, it would not print out the percentage counter. Thanks in advance :)