-1

I have a crontab command for a python script that prints out files matching certain criteria in a directory. the script prints out the files in a for loop. I then pipe that command to tee the stdout to a file in another directory, and then remove those files through another pipe.

here is the command:

* * * * * ssh someserver.us.com "python /path/to/my/script.py | tee /path/to/my/text_file.txt | xargs rm"

I tested this out manually in linux, and it outputs to the txt file fine.

however, when the cron job (using the same command, but for a different output) runs, it clears that same txt file.

it seems to be only in cron does this work in a weird way..

i'm not too well versed in cron nor linux, so any help would be greatly appreciated!

  • 1
    I'm voting to close this question as off-topic because it's not about programming and it belongs to https://unix.stackexchange.com/questions – tink Nov 30 '18 at 16:40

1 Answers1

1

SUGGESTION: Change your command to tee -a myfile.txt:

Here's the documentation for "tee":

http://man7.org/linux/man-pages/man1/tee.1.html

paulsm4
  • 114,292
  • 17
  • 138
  • 190