Page MenuHomePhabricator

Please add an option for name of the log files
Closed, DuplicatePublicFeature

Description

Please add an option for creating logfiles elsewhere, not in the home directory of the tool.

I have currently, but slowly growing, 49 different scripts, a few run every day, some once a week, some once a month.

To have an (almost) clean homedirectory of my tool, I write all log info to a directory "logs".

With toolforge-jobs I end up with close to 100 additional files. I do not really like that.

Yes, I can add the option --no-filelog which supresses the log. But this prevents me from checking for some problem after that problem occurred, I have no log, nothing.

I tried --command "php ~/spielwiese/tf_test.php >>logs/tf_test.out 2>>logs/tf_test.err" but that did not work.

So after a while, I found this solution:
$ chmod +x nice_file.php
$ cat nice_file.php

#!/usr/bin/bash
exec php -- $@ >>~/logs/nice_file.out 2>>~/logs/nice_file.err <<"EOF"
<?php
print date('Y-m-d H:i:s', time()) . " End nice_file.php\n";
?>
EOF

and can start the job with toolforge-jobs run nicejob --command "~/sandbox/nice_file.php" --image tf-php74 --wait --no-filelog

Live could be much easier with an option for simple redirecting the log files …