How to redirect stderr and stdout to custom file in circleci background process

circle.yml

#1

By default, if I start a background web server with 2 workers, I get 4 files to sift through when debugging. I would like to have a single file to search.

  • gunicorn mybase.wsgi --workers 2:
    background: true

stdout_gunicorn_12781.txt
stdout_gunicorn_12794.txt
stderr_gunicorn_12733.txt
stderr_gunicorn_12755.txt

If I try to redirect output of stdout and stderr to a single file like I do on my dev box, it fails to save any output in circleci:

circle.yml way doesn’t let me redirect output to custom file

  • gunicorn mybase.wsgi --workers 2 > gunicorn_2_workers.txt 2>&1:
    background: true

linux equivalent: (this command fails on circleci)
nohup gunicorn mybase.wsgi --workers 2 > gunicorn_2_workers.txt 2>&1 &

Anyone know how to redirect output to custom file when using background processes on circleci?


#2

yea I used to successfully use… * digs ups old commit * …

  • java -jar sel.jar -app app.apk &> output_from_selendroid:
    background: true

so &> will redirect both stderr and stdout to a file called output_from_selendroid in my ~/[RepoName]/


#3

Hi gundal,

I tested that out in both test > pre and test > override on multiple processes. However it had no effect. Maybe circleci changed the way they handle stdout and stderr since you used that technique?


#4

If you SSH in, is the file there? Perhaps you forgot to make sure the file you’re writing to is under $CIRCLE_ARTIFACTS, so it’s in your homedir or the project dir but not in the artifacts dir?


#5