-   Linux - Software (
-   -   regular print job using cron or something ? (

bigjohn 03-31-2005 08:19 AM

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.



win32sux 03-31-2005 08:29 AM

bigjohn 03-31-2005 01:14 PM

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 !




win32sux 03-31-2005 06:39 PM

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:


# 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:


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

Brian1 03-31-2005 07:38 PM

This is what I would do.
Type ' lpstat -p ' to list printer names. Example of mine.

[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/ '. This prints the file 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

# command prints the test page to my PhotoSmart Printer
/usr/bin/lpr -P PhotoSmart /usr/share/cups/data/

Then make it executable by typing ' chmod +x /etc/cron.weekly/refresh_carditages

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

" Google the Linux way @ "

win32sux 03-31-2005 07:43 PM

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:


ps aux | grep crond

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


Brian1 03-31-2005 08:07 PM

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.


win32sux 03-31-2005 08:32 PM

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


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/

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:


/usr/bin/lpr -P epy /usr/share/cups/data/

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:


9 30 * * 1 /usr/bin/lpr -P epy /usr/share/cups/data/

Brian1 03-31-2005 10:14 PM

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/

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

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

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.

All times are GMT -5. The time now is 12:23 AM.