Jump to content

Recurring Cron - Ubuntu 10.4 Issue


thomas@

Recommended Posts

Good day guys.

I was woundering if anyone else has had this issue.

Got me stumped at the moment.

I am runing Ubuntu 10.4 trying to setup a recuring cron job. (will run script to start and monitor)

Any how i decided to go gui and install the gnome-scheduler (went fine)

I then tried to keep things simple and make one recuring task via gui.

Problem:

=======

Recuring tasks are not runing (keeping it simple even the simplest of comands do not run)

However one time tasks run fine

I have adding new tast with contab -e (same results)

there are no allow/deny files in /etc/

In system log file i see crontab call but no errors

any suggestions would be greatly apreshated.

Link to comment
Share on other sites

Can you post the crontab entry that is giving you the problem?

Sparda thanks,

Here is what i currently have in there at the moment none of them are working. Will only be two in there when its done i have just been testing with diffrent variations

05 11 * * * vbetool dpms off > /home/thomas/logfile # JOB_ID_1

35 9 * * * vbetool dpms on # JOB_ID_2

58 23 * * * xset s off # JOB_ID_3

50 8 * * * xset s on # JOB_ID_4

07 11 * * * /home/thomas/cronscripts/monitorcontrol.sh off # JOB_ID_5

What i would like to do is have cron call twice one in at night with the option off and one in the morning with the option are to the script at /home/thomas/cronscripts/monitorcontrol.sh off

the script it self is here

#!/bin/bash

export DISPLAY=:0.0

if [ $# -eq 0 ]; then

echo usage: $(basename $0) "on|off|status"

exit 1

fi

if [ $1 = "off" ]; then

echo -en "Turning Screensaver off..."

xset s off

echo -en "Turning monitor off..."

vbetool dpms off

echo -en "done.\nCheck:"

xset -q|grep "Monitor is"

elif [ $1 = "on" ]; then

echo -en "Turning Screensaver on..."

xset s on

echo -en "Turning monitor on..."

vbetool dpms on

echo -en "done.\nCheck:"

xset -q|grep "Monitor is"

elif [ $1 = "status" ]; then

xset -q|sed -ne 's/^[ ]*Monitor is //p'

else

echo usage: $(basename $0) "on|off|status"

fi

Like i said scripts and commands work fine if setup as one time task but do not work as recurrent task

thank you so much for your help...

Link to comment
Share on other sites

When you create entries in crontab always use the full absolute path for the binary/script it is to run, the cron daemon does not know to look in the various binary directories.

Generally you will also need to specify where stdout and stderr go. You have directed stdout on the first script, so leave that one as it is, though you will have to add "2> /dev/null" to it (redirect stderr to /dev/null). So the full thing for the first entry will be as follows

05 11 * * * /fullpath/to/file/vbetool dpms off > /home/thomas/logfile 2> /dev/null # JOB_ID_1

Then add > /dev/null 2> /dev/null to the rest of the entries.

Link to comment
Share on other sites

When you create entries in crontab always use the full absolute path for the binary/script it is to run, the cron daemon does not know to look in the various binary directories.

Generally you will also need to specify where stdout and stderr go. You have directed stdout on the first script, so leave that one as it is, though you will have to add "2> /dev/null" to it (redirect stderr to /dev/null). So the full thing for the first entry will be as follows

05 11 * * * /fullpath/to/file/vbetool dpms off > /home/thomas/logfile 2> /dev/null # JOB_ID_1

Then add > /dev/null 2> /dev/null to the rest of the entries.

Still no luck

current line is

58 1 * * * /usr/sbin/vbetool dpms off > /home/thomas/logfile 2> /dev/null # JOB_ID_1

Now just as another test i added this as a one time tast and worked fine just like the others.

Question is why does one time only task work with same commands and recurrent task does not.

it totaly has me stumped i have been back and forth and secound guessing everything...

Edited by h1kar1
Link to comment
Share on other sites

Sparda

Thank you for your help i figured it out it did have to do with absolute paths.

here is the final work out

crontab -e

========

55 23 * * * sh /home/thomas/cronscripts/monitorcontrol.sh off > /home/thomas/cronscripts/log 2>&1 # JOB_ID_5

55 08 * * * sh /home/thomas/cronscripts/monitorcontrol.sh on > /home/thomas/cronscripts/log 2>&1 # JOB_ID_7

Config

========

#!/bin/bash

export DISPLAY=:0.0

if [ $# -eq 0 ]; then

echo usage: $(basename $0) "on|off|status"

exit 1

fi

if [ $1 = "off" ]; then

echo -en "Turning Screensaver off..."

/usr/bin/xset s off

echo -en "Turning monitor off..."

/usr/sbin/vbetool dpms off

echo -en "done.\nCheck:"

/usr/bin/xset -q|grep "Monitor is"

elif [ $1 = "on" ]; then

echo -en "Turning Screensaver on..."

/usr/bin/xset s on

echo -en "Turning monitor on..."

/usr/sbin/vbetool dpms on

echo -en "done.\nCheck:"

/usr/bin/xset -q|grep "Monitor is"

elif [ $1 = "status" ]; then

/usr/sbin/xset -q|sed -ne 's/^[ ]*Monitor is //p'

else

echo usage: $(basename $0) "on|off|status"

fi

thanks again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...