LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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

Reply
 
Search this Thread
Old 12-19-2013, 08:49 AM   #1
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Rep: Reputation: Disabled
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
 
Old 12-19-2013, 09:04 AM   #2
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,041

Rep: Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630
do the lpq / lprm and like commands do anything for you ?
 
Old 12-19-2013, 09:17 AM   #3
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
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..
 
Old 12-19-2013, 10:17 AM   #4
Spect73
Member
 
Registered: Aug 2013
Distribution: Slackware 14.1
Posts: 128

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 12-19-2013, 11:04 AM   #5
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
Spect73, if you do not want to help, please do not waste my time with your useles and helpless suggestions. No Thanks
 
Old 12-19-2013, 12:11 PM   #6
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
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
 
Old 12-19-2013, 12:55 PM   #7
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,041

Rep: Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630Reputation: 630
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).

Last edited by schneidz; 12-19-2013 at 12:56 PM.
 
1 members found this post helpful.
Old 12-19-2013, 01:21 PM   #8
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.
 
Old 12-19-2013, 01:32 PM   #9
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,646

Rep: Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575
Quote:
Originally Posted by randy-e View Post
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.
 
2 members found this post helpful.
Old 12-19-2013, 01:39 PM   #10
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
TBOne, thanks for nothing, no thanks
 
Old 12-19-2013, 04:53 PM   #11
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,646

Rep: Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575
Quote:
Originally Posted by randy-e View Post
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.
 
1 members found this post helpful.
Old 12-20-2013, 09:00 AM   #12
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 12-20-2013, 09:13 AM   #13
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,646

Rep: Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575Reputation: 2575
Quote:
Originally Posted by randy-e View Post
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.

Last edited by TB0ne; 12-20-2013 at 09:29 AM.
 
1 members found this post helpful.
Old 12-20-2013, 01:13 PM   #14
randy-e
LQ Newbie
 
Registered: Dec 2013
Posts: 8

Original Poster
Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to remove files older than 3 days rust8y Linux - General 26 10-04-2012 08:26 AM
Bash script to remove files older than x days henkoslaw Linux - General 1 06-10-2012 03:55 AM
[SOLVED] Script: find, compress, remove original files, older than x days? blacklion Linux - General 5 02-27-2012 10:22 AM


All times are GMT -5. The time now is 01:31 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration