I got some long running bash scripts on my Ubuntu 10.04 Server that are doing things like backups and database dumps.
I'm currently executing them via cron and mailing me the results. However it would be nice to trigger them manually throughout a Webinterface additionally. (I do not want to give any user SSH access so he can trigger the scripts)
In PHP, for instance, there is the exec Command which obtains the Script output AFTER the Script has finished. This is not useful since the Scripts last longer than the 30 Seconds Browser Timeout. (And I want to monitor the progress) So I'm currently stuck in finding a way on how to gather the Script output periodically or "tailing" and display it through JavaScript or Pagereloads or something like that.
As I noticed, Webmin for instance is somehow doing this when you run system commands like apt through their webinterface.
One way I could imagine is forking the script execution and redirecting the output to a file, whilst the Main Process is reading it on Page reload/ Ajax request. But this sounds somehow like a workaround :)
So, does anyone have a good solution for this problem? Doesn't need to be PHP, could also be python or perl or anything else on server side. Or is there a tool or library for such things?
Any ideas greatly appreciated!