LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell script to remove print jobs older than xx days (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-to-remove-print-jobs-older-than-xx-days-4175488553/)

randy-e 12-19-2013 08:49 AM

Shell script to remove print jobs older than xx days
 
Am looking for a shell script that will allow me to remove old print jobs that are in the cups print queue, preferably based on days old, like 5 days or older print jobs will be removed. Do not want a complicated perl script, just as simple as possible shell script, i do not know how to script at all at this point.

Thanks

schneidz 12-19-2013 09:04 AM

do the lpq / lprm and like commands do anything for you ?

randy-e 12-19-2013 09:17 AM

if there is a command syntax to remove based on days old that would be fine also, do not want to have to keep manually removing them by job or print queue all of the time, want to be able to enter one command and have all print jobs older than xx days removed. Thanks..

Spect73 12-19-2013 10:17 AM

Most Linux distros come with print managers that allow you to specify deleting the file after it is printed. Since you don't wish to learn shell scripting at this point, perhaps you should investigate what your distro provided.

Also, reading tutorials->linuxquestions.org->how-to-ask-a-question might be of help.

randy-e 12-19-2013 11:04 AM

Spect73, if you do not want to help, please do not waste my time with your useles and helpless suggestions. No Thanks

randy-e 12-19-2013 12:11 PM

I just signed up as a member today, the ? that I asked is one that millions should ask, I have searched the web and have not found any of the example shell scripts to work, this should be something simple and easy to do in a robust OS as Linux, but I have looked and either have overlooked it or it is not there. I can not believe that someone else has not wanted this and I do not believe in recreating the wheel. Thanks

schneidz 12-19-2013 12:55 PM

i dont have a printer simply because they are a waste of paper and ink. if i were to buy a printer then i would probably create a bash 1-liner using lpq and save the output to a log. then every 3 days cron would read the log and lprm all the print jobs on the log. (maybe even print a page repeating the line "all done <@:)" just for the shiggles).

randy-e 12-19-2013 01:21 PM

schneidz, thank you for your response, but we have 100's of printers on our linux server, i really just want a simple script that i can run whenever i want to run it or a command line command that allows me to put in xx days and back to remove print jobs for, we have a lot of people who if a printer does not print,they keep trying and trying and those print jobs get stuck in the queue and never clear, is there some setting in cups that would remove old print jobs based on days? Thanks again.

TB0ne 12-19-2013 01:32 PM

Quote:

Originally Posted by randy-e (Post 5084036)
I just signed up as a member today, the ? that I asked is one that millions should ask, I have searched the web and have not found any of the example shell scripts to work, this should be something simple and easy to do in a robust OS as Linux, but I have looked and either have overlooked it or it is not there. I can not believe that someone else has not wanted this and I do not believe in recreating the wheel. Thanks

The very first hit in Google for "linux script to purge print jobs older than" is:
http://www.mnxsolutions.com/linux/cu...lder-than.html

...is a fully-functional Python script to do just that.
Quote:

Originally Posted by randy-e
Spect73, if you do not want to help, please do not waste my time with your useles and helpless suggestions. No Thanks

Please see many of the existing LQ Threads where people come and ask for scripts to be written FOR THEM...they don't get much help, if any. We are always happy to assist, but since YOU need the script, YOU need to show some effort of your own, and tell us what you've done, and where you're stuck.

I'll agree with Spect73...if you don't want to learn how to write your own bash scripts, you'll have to use the tools that are available to you with your distro. There are many easily-found bash scripting tutorials...combine them with the man pages on lpq/lpqrm, and you have the tools necessary for you to do this yourself, rather than complaining that others haven't just done it for you.

randy-e 12-19-2013 01:39 PM

TBOne, thanks for nothing, no thanks

TB0ne 12-19-2013 04:53 PM

Quote:

Originally Posted by randy-e (Post 5084088)
TBOne, thanks for nothing, no thanks

Aside from GIVING YOU a script that does EXACTLY what you're after, what more did you expect?? It was looked up for you, and given to you...if you want people to write scripts for you, post it in the LQ Job Marketplace (along with how much you're willing to PAY to have someone do your programming for you), and you'll have a script in no time.

Otherwise, show some effort of your own...and given your fairly rude attitude towards folks who have tried to help you, and the laziness you've displayed by not even TRYING to do it yourself, don't be surprised when people don't fall over themselves to write programs for you...for free.

randy-e 12-20-2013 09:00 AM

TBOne, I am extremely sorry, I was so frustrated and in a hurry yesterday that I missed the link that you had included in your reponse. I had spent over 4 hours trying to figure something out before I finally gave up and signed up on this forumn, I suffer from an Anxiety Disorder and when I get frustrated, it snowballs down hill on me, I was at the point that I just needed a solution that would work, as I stated orginally that I do not know script coding at all. Please forgive me for my rudeness yesterday, I have had time to calm down. Thanks very much for your patience, I will try the script that you suggested and see how it works. Take Care.

TB0ne 12-20-2013 09:13 AM

Quote:

Originally Posted by randy-e (Post 5084506)
TBOne, I am extremely sorry, I was so frustrated and in a hurry yesterday that I missed the link that you had included in your reponse. I had spent over 4 hours trying to figure something out before I finally gave up and signed up on this forumn, I suffer from an Anxiety Disorder and when I get frustrated, it snowballs down hill on me, I was at the point that I just needed a solution that would work, as I stated orginally that I do not know script coding at all. Please forgive me for my rudeness yesterday, I have had time to calm down. Thanks very much for your patience, I will try the script that you suggested and see how it works. Take Care.

No worries, thanks, and I hope that program helps you. But please do consider learning how to write scripts, since that knowledge will save you THOUSANDS of hours in the future, by being able to 'just do' tasks like this in minutes.

The Linux Documentation Project (TLDP) is a great resource:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...ers-Guide.html
http://www.tldp.org/LDP/abs/html/

...which takes you from the VERY beginning to pretty advanced concepts, complete with examples and sample source code.

Good luck to you.

randy-e 12-20-2013 01:13 PM

TBOne, the python script from the link you gave me works perfectly for what I need, it works great from the command line, some people said they could not get it to work thru cron, but I am not planning on running it thru cron at this time. Thanks for your help and for the suggestion to learn more about scripting, thanks for the links to that also. Take Care.


All times are GMT -5. The time now is 03:02 PM.