cancel
Showing results for 
Search instead for 
Did you mean: 

Cron Job to enable printer

Kelly M_1
Advisor

Cron Job to enable printer

Hi I am very much a HP UX newbie. We are having issues with printers disabling themselves do to network issues. To get around this have tried to setup a cron job found in this http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1245852100886+28353475&threadId=299627 forum post.

It does not seem to be working and when I do a ./scriptname I get the error Execute permission denied. I'm not sure where to go from here.
10 REPLIES
Mark S Meadows
Valued Contributor

Re: Cron Job to enable printer

Hi Kelly,

What are the actual permissions on the script file you have created, i.e. :

/home/markme# ll scriptname
-rwxr-xr-x 1 markme users 20 Jun 24 15:15 scriptname
gba70102:/home/markme#

You need execute permissions on file in order to execute it.

Regards,

Mark
Administrating HP-UX systems for more years than I care to admit, but still enjoying it (most of the time!).
Ganesan R
Honored Contributor

Re: Cron Job to enable printer

Hi Kelly,

Error indicates that, you donot have execute permission on the script. Are u running the script as root user?

Run this command and try to execute the script.

# chmod u+x scriptname

or

# chmod 755 scriptname
Best wishes,

Ganesh.
gstonian
Trusted Contributor

Re: Cron Job to enable printer

'chmod' the file

'man chmod' for more info on this command :)
TTr
Honored Contributor

Re: Cron Job to enable printer

The "scriptname" must have its execution bit set. Type "ll scriptname" to see its permission mode and "chmod 700 scriptname" to set it.

Read the man page for ll "man ll" to see an explanation about permission modes. They are the -rwxr-xr-x that you see in the directory listing with the "ll" command.
Kelly M_1
Advisor

Re: Cron Job to enable printer

Wow lots of great help on this forum. I have set the script permissions to make it executable. It now runs when I type ./scriptname Does that mean it will run as a cron job now?

Thanks for the quick responses
Mark S Meadows
Valued Contributor

Re: Cron Job to enable printer

Kelly,

It depends upon what is in the actual script ! You will need to ensure that the path for any commands is in included, i.e. set the PATH variable - this often gets overlooked :

#!/sbin/sh
PATH=/usr/sbin:/usr/bin:/sbin
~
~

Regards,

Mark
Administrating HP-UX systems for more years than I care to admit, but still enjoying it (most of the time!).
Sunny123_1
Esteemed Contributor

Re: Cron Job to enable printer

Hi

Did you make an entry in cronjob???
If no then make entry for scriptname in cron.

#crontab -e
10 * * * * <script>

It will run script after every 10 minute.

Regards
Sunny
Kelly M_1
Advisor

Re: Cron Job to enable printer

I added the following line to crontab -e

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/cron/scriptname 2>&1
TTr
Honored Contributor

Re: Cron Job to enable printer

Cron sends the output of every job it runs in an email. Check root's email to see if there are any errors in the execution of the script.
You can also check the cron log in /var/adm/cron/log. You will recognize the scriptname and two lines showing the start and end of execution.
Mark S Meadows
Valued Contributor

Re: Cron Job to enable printer

Kelly,

You can test the script to see if it will work ok under cron via the following :

batch
/fullpathname/scriptname
CTRL-D

If your script works with batch it should also work with cron.

Regards,

Mark
Administrating HP-UX systems for more years than I care to admit, but still enjoying it (most of the time!).