I'm reading this post and I don't fully follow the answer.
I wondered if I could modify this, what's it called, command redirect?
What I would like:
- Don't hang, use ampersand
&to move on to the next command - Output the data generated by the command to file
data.json - Any problems, error messages or issues running the command, output them to bqlog.txt
Is this possible?
E.g. I currently have this command:
bq query --max_rows=1000000 --use_legacy_sql=false --format=json --batch=true --headless=true 'select * from `ga4-extract.analytics_123456789.events_'"$RUNDATE"'`;' > data.json
It's failing after about 30 minutes and I cannot see the output or what the issue is. This is on a github actions runner and the console output of the workflow just gives a failed status but, unique to this workflow, no console output indicating the error.
I wanted to modify my command so that I can output to data.json like I already have, but then also move on to the next step of monitoring the bqlog.txt file with tail -F bqlog.txt
>txtonly logs normal output. By using2>&1you say, I want stderr to be redirected to whatever my output already is. so>txt 2>&1basically makes stderr also output to txt – LPChip Jul 30 '22 at 21:30&does not mean ‘append to’, that would be>>. – user3840170 Jul 31 '22 at 06:24^to break long lines in bat/cmd scripts. – Jonathan Jul 31 '22 at 07:08>>, it's also different from a regular one (>), also in that the regular mode truncates the file first.&only tells to copy an existing file descriptor, it does not change between regular and append mode. (the answer also uses the proper meaning of the word later) – ilkkachu Jul 31 '22 at 09:05