logging session automatically



I would like to log sessions automatically, saving to a file created 
at the start, then closing before exiting maxima. (both on linux and on
mswindows)

I have tried using 'writefile', but i wasn't able to execute 
maxima batch commands without exiting in the end.
Moreover, i wasn't able to create the file exploiting system utilities  
to include date in the filename.

Any suggestions?  

Thank you 

--
Pol