Setting up a cron job to backup an errors file once a month

If none of the more specific forums is the right place to ask

Setting up a cron job to backup an errors file once a month

Postby Lady Aleena » 2019-09-03 08:34

Hello everyone.

Yesterday I was looking at my directory listing without human readable on, when I saw that ~/.xsession-errors was over 17M. I opened it to see what was in there and saw mostly warnings. After investigating for a while with the help of the good people on IRC, I was guided to the conclusion to let things be. However, I would like to have a more sane ~/.xsession-errors file in my home directory.

So, what I would like to do is copy the current error file into a directory called ~/.xsession-errors-logs at midnight on the first day of the month with the name .xsession-errors-YYYY-MM-DD. Then I would like the error file in my home dir cleared for the next month's errors. Also, I would like to keep the amount of files in the -logs directory down, so would like to delete the file from six months prior.

Now, I have known about cron jobs but have not used them before. I looked into it, and it appears that it would be better if I scripted the above commands, and then put that script into the cron job. However, I am not sure the best way write the script to get what I want.

I don't even know if I am thinking about this correctly, so any corrections to how I should think about this would be wonderful.

I appreciate all help offered. Thank you for reading.
Lady Aleena
Posts: 20
Joined: 2013-12-06 07:48

Return to General Questions

Who is online

Users browsing this forum: No registered users and 9 guests