Shell script to remove print jobs older than xx days
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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..
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.
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
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).
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.
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
...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.
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.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.