LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-31-2005, 08:19 AM   #1
bigjohn
Senior Member
 
Registered: Jun 2002
Location: UK .
Distribution: *buntu (usually Kubuntu)
Posts: 2,690
Blog Entries: 9

Rep: Reputation: 45
regular print job using cron or something ?


The problem, well I don't do much printing. I have both a laser printer and an inkjet, the laser isn't a problem - dry toner etc, but the inkjet suffers from dried out cartridges/blocked and/or unblockable jets.

I've looked into things a little, and it would appear that I should configure/install/setup (whatever) cron to print off a test page once a week or so.

I appear to have it installed, but I don't even know where to start with configuration. I suffer from personal stupidity when it comes to decyphering Linux docs. I've found that even so called "newb documentation" means the square root of f*** all to me.

I found this link but even that's over my head.

does anyone know of a stage by stage howto, that will explain how I configure cron (or vixie cron or kcron or Anacron etc etc) ? (preferably written in english, not technoblurb).

Any assistance much appreciated.

regards

John
 
Old 03-31-2005, 08:29 AM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
http://www.lysator.liu.se/~forsberg/linux/cron.html

http://www.linuxhelp.net/guides/cron/

http://www.scrounge.org/linux/cron.html


Last edited by win32sux; 03-31-2005 at 08:31 AM.
 
Old 03-31-2005, 01:14 PM   #3
bigjohn
Senior Member
 
Registered: Jun 2002
Location: UK .
Distribution: *buntu (usually Kubuntu)
Posts: 2,690

Original Poster
Blog Entries: 9

Rep: Reputation: 45
Thanks for the links win32sux, but I'm still flummoxed. The first two, mention a file called /etc/crontab - my system says "file /etc/crontab does not exist". Sure, I can find directories in /etc/ called cron.daily, cron.hourly, etc etc, but nothing (directory or file) that says "crontab". I also don't have much of a clue as to how I'd work out what I'd need to put in to a command to make my inkjet printer start (irrespective of how often) and print a test page (even a cups test page would do).

Maybe there's a cron type app that has a graphic frontend so I can just set it up that way, but I doubt it or I'm convinced that I'd have seen mention of it! The only thing that I've found thus far, is kcron, but that's only got a very vague KDE type dialogue box, and if I look at the kcron help, it just goes off about variables and other stuff that I have absolutely no knowledge of !

Damn!

regards

John
 
Old 03-31-2005, 06:39 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
on my home pc (slackware) the crontabs are in /var/spool/cron/crontabs/

to edit a crontab i use the command "crontab -e"... if i execute that command as root, then i am editing root's crontab... if i execute the command as win32sux, then i am editing win32sux's crontab... currently i haven't cronned anything here at home, so my win32sux crontab is empty, and my root crontab has the default slackware stuff which calls those cron.daily, cron.hourly, cron.monthly, and cron.weekly directories you've already seen...

my root crontab looks like this:

Code:
# If you don't want the output of a cron job mailed to you, you have to direct
# any output to /dev/null.  We'll do this here since these jobs should run
# properly on a newly installed system, but if they don't the average newbie
# might get quite perplexed about getting strange mail every 5 minutes. :^)
#
# Run the hourly, daily, weekly, and monthly cron jobs.
# Jobs that need different timing may be entered into the crontab as before,
# but most really don't need greater granularity than this.  If the exact
# times of the hourly, daily, weekly, and monthly cron jobs do not suit your
# needs, feel free to adjust them.
#
# Run hourly cron jobs at 47 minutes after the hour:
47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null
#
# Run daily cron jobs at 4:40 every day:
40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null
#
# Run weekly cron jobs at 4:30 on the first day of the week:
30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null
#
# Run monthly cron jobs at 4:20 on the first day of the month:
20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null
if i wanted to add a cron task that would (for example) delete a certain directory every sunday morning at 7:05am, i would add a line that looks like this:

Code:
7 05 * * 0 /usr/bin/rm -fr /example_dir

Last edited by win32sux; 03-31-2005 at 08:14 PM.
 
Old 03-31-2005, 07:38 PM   #5
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 64
This is what I would do.
Type ' lpstat -p ' to list printer names. Example of mine.
Code:
[crusher58@lcomp58 data]$ lpstat -p
printer OfficeJet is idle.  enabled since Jan 01 00:00
printer PhotoSmart is idle.  enabled since Jan 01 00:00
        Print file sent, waiting for printer to finish...
Now I type the command ' /usr/bin/lpr -P PhotoSmart /usr/share/cups/data/testprint.ps '. This prints the file testprint.ps to my PhotoSmart printer.

Next to run it in cron. If you have a directory called /etc/cron.weekly then create a script like this.
Contents of the script called ' refresh_carditages ' and put it in /etc/cron.weekly. Final /etc/cron.weekly/refresh_carditages
Code:
#!/bin/bash
# command prints the test page to my PhotoSmart Printer
/usr/bin/lpr -P PhotoSmart /usr/share/cups/data/testprint.ps
Then make it executable by typing ' chmod +x /etc/cron.weekly/refresh_carditages

If not there do a ' whereis cron.weekly ' or ' whereis cron '.

Brian1
" Google the Linux way @ http://www.google.com/linux "
 
Old 03-31-2005, 07:43 PM   #6
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
BTW, if you don't wanna muck with the crontab yet and just want to get your thing printed weekly with minimum fuss then just create a shell script that prints your thing (make sure you test it) and then put it in the /etc/cron.weekly/ directory... it will automatically get executed by cron on a weekly basis... for example: take a look at my crontab above, if i was to drop a script into the /etc/cron.weekly directory it would get executed at 4:30am on sundays - without me having to do anything besides place the script in the directory...

of course you need to make sure you are running cron for it to work:

Code:
ps aux | grep crond

EDIT: well, seems like Brian1 beat me to the cron.weekly suggestion... hehe...

=)


Last edited by win32sux; 03-31-2005 at 08:13 PM.
 
Old 03-31-2005, 08:07 PM   #7
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 64
Its nice when great minds think alike there win32sux. Nothing beats the simplicity of scripts.
Just had a thoght here. Not sure if the testprint uses both color and black cartiages to do this. Mostly wanted to print a color image to keep the color going. I think if you print a text file it uses the black cartiage then. Not sure though. Might need to add a line to print a small text file to printer to make sure you get the black one as well.

Brian1
 
Old 03-31-2005, 08:32 PM   #8
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 379Reputation: 379Reputation: 379Reputation: 379
i just did the Brian1-style test page print like so:

Code:
bash-3.00$ lpstat -p
printer epy is idle.  enabled since Jan 01 00:00
bash-3.00$ lpr -P epy /usr/share/cups/data/testprint.ps
it successfully printed the test page in black and white mode, which is what i have configured in the default options section of the cups thing on http://localhost:631 (i have an HP Deskjet 3420 Color/BW)...

so yeah, like Brian1 said: i could make a simple shell script now:

Code:
#!/bin/sh
/usr/bin/lpr -P epy /usr/share/cups/data/testprint.ps
then i'd just "chmod 755" it and drop it into /etc/cron.weekly and i'm done...

or if i want more control i can crontab it for mondays at 9:30am (for example) by putting this in my crontab:

Code:
9 30 * * 1 /usr/bin/lpr -P epy /usr/share/cups/data/testprint.ps
=)


Last edited by win32sux; 03-31-2005 at 08:37 PM.
 
Old 03-31-2005, 10:14 PM   #9
Brian1
LQ Guru
 
Registered: Jan 2003
Location: Seymour, Indiana
Distribution: Distribution: RHEL 5 with Pieces of this and that. Kernel 2.6.23.1, KDE 3.5.8 and KDE 4.0 beta, Plu
Posts: 5,700

Rep: Reputation: 64
Well still giving this a thought. I believe if one passes the -o option. My default is color so I think it did not use the black to print. Could be wrong here.

If anyone has an idea on how to print in grayscale when default printer setting is set for color please pass them along. Thanks for your time and help.

Not having any luck printing in grayscale yet. Options tried.
/usr/bin/lpr -P PhotoSmart -o Resolution=300DraftGrayscaleCMYK /usr/share/cups/data/testprint.ps

/usr/bin/lpr -P PhotoSmart -o ColorMode=Gray /usr/share/cups/data/testprint.ps

/usr/bin/lpr -P PhotoSmart -o ColorMode=Grayscale /usr/share/cups/data/testprint.ps



Wonder what other options one can pass. Found this browsing the web.
lpr -o 'sides=two-sided-long-edge'
lpr -o 'sides=two-sided-short-edge'

Normally though you'd configure your printer to do duplex by
default. For cases where you need single sided do:

lpr -o 'sides=one-sided'

Oh well it has been a learning experience tonight. Time for Bed.
Brian1
 
  


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
cron job? dr_zayus69 Linux - Newbie 14 12-01-2004 07:16 PM
cron job sanjith11 Linux - General 5 07-14-2004 02:06 PM
cron job to print message to all ehpserver Linux - Newbie 1 02-28-2004 10:08 PM
cron job thesnaggle Linux - Newbie 1 09-19-2003 11:47 AM
cron job? luap Linux - Software 2 03-16-2003 09:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration