Problem with pipe command (pv)

SYSTEM INFORMATION
OS type and version Ubuntu 22.04
Webmin version 21.09.5
I have some scripts that use the pv command to show progress. The scripts run fine from the Webmin terminal but if I run them as a cron job the Webmin main window output seems to ignore the pv function and shows script progress as a scrolling page of output . This is not a major problem but just wondering why - is it because of a setting somewhere in the webmin configuration or am I doing something wrong.?

Does pv require a terminal to show the display ? I would guess so, a cronjob does not have a terminal as such and will display the textual output and not any ansi sequences etc

Because it’s not a terminal! pv uses a bunch of terminal escape codes to make that fancy progress bar. Most of the places in Webmin where you can run a script or command are not a terminal (only the Terminal in Webmin is an actual terminal, and it’s quite heavy…has to start a backend WebSockets process for each session, which takes a little time and some resources).

But, also why would you use pv in a cron job!? cron is also not a terminal and can’t possibly do anything useful with pv.

1 Like

Thank you for the feedback. As mentioned in my post this is not a major concern. Granted that under normal circumstances cron jobs would be running in the background with nobody watching.
I have a cron job that runs several scripts in sequence and at the end of each task a message is generated giving status of the task. In the event that someone needed to run the cron job manually I was experimenting with the idea of providing feedback as to what was going on but the scrolling of the output from the cron job the screen fills up so quickly that you don’t see the output messages except for the last one. But as I said I just wondered why the pipe did not work and you have explained it.
I have tried sending the output messages via email but never got it to work. I can send a test email from webmin but nothing from the cron jobs themselves. I think the default is only failures are sent but I have tried introducing failures but there are no emails. Reading other posts on this subject indicate that you need to put
MAILTO=$email
on top of the cron script.
but my attempts at doing this fail - if I edit the cronjob like this it seems to destroy the actual cronjob.
.Any advice on this would be welcome.

MAILTO=a real email address
rather than
MAILTO=$email
Works for me.
But i would add a cron enviroment variable via the webmin interface with the perfered email address

Thank you,
As reported sending the test email to my gmail address works ok.
I have added MAILTO=“my gmail address” in the "Input to Command’ field in cron jobs. but get no email on cron job failure - am I putting the MAILTO in the wrong place??
Eric

I set it as enviroment variable rather than input. The down side is that all cron emails get sent to that email address. If its just for a single job redirect the output of the cronjob to mail something like

/var/www/dir/sh/mysql_dump.sh 2>&1 | mail -s “email subject” email@address.com

in the cron command text box

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.