Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to output a job's output to stdout? #33

Open
x-yuri opened this issue Sep 28, 2021 · 8 comments
Open

A way to output a job's output to stdout? #33

x-yuri opened this issue Sep 28, 2021 · 8 comments

Comments

@x-yuri
Copy link

x-yuri commented Sep 28, 2021

That would be most welcome for running dcron in a docker container. Then there'd no need to set up mail, and docker logs could be used to inspect what's going on.

@ttionya
Copy link

ttionya commented Jun 28, 2022

@x-yuri , I have the same issue, did you find a way to output job's output to stdout? Or are you using another cron?

@x-yuri
Copy link
Author

x-yuri commented Jun 28, 2022

@ttionya I didn't find a way to make dcron output to stdout. I've found slicd, which is an old unsupported piece of software, but it works. There's also this gist, but I'm not sure if it works. UPD Oh, there's my comment there, so supposedly it does, but with rsyslog.

@x-yuri
Copy link
Author

x-yuri commented Jun 28, 2022

...And even under Alpine Linux w/o rsyslog.

@x-yuri
Copy link
Author

x-yuri commented Jun 28, 2022

Actually, even with dcron it seems to work under Alpine Linux.

@KingDuckZ
Copy link

Also looking for a way to achieve this, possibly without any extra software. I don't see the point of installing and configuring a mail server just for logging the output of a couple scripts, it's easier and more practical to have all the logs in one place

@ttionya
Copy link

ttionya commented Jun 28, 2022

@x-yuri , Thanks for the quick reply, I saw your reply a few hours ago but I was in a hurry to go to the hospital so I didn't reply in time.

My current cron configuration is * * * * * bash xxx.sh > /dev/stdout, but there is no output from dcron (busybox cron works fine), I will try to change it to /proc/1/fd/1 and test if it works.

My requirement is simple, execute the script regularly and docker logs can see the stdout of the script. I think it's a good idea to write the stdout of the script to a file and start crond in the background, and docker's entrypoint executes tail -f to listen for changes in the contents of the file. I'll try it out and post the results here later.

@ttionya
Copy link

ttionya commented Jun 28, 2022

I'll try it out and post the results here later.

Both methods, > /proc/1/fd/1 and redirecting the output file to a file and then reading the contents of the file via tail -f will print the stdout of the script properly. @x-yuri @KingDuckZ

I would choose /proc/1/fd/1 because it is very simple.

@KingDuckZ
Copy link

Thanks but I switched to cronie and configured it to run with -s -m off which does just what I want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants