Crontab help

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

davidh
Posts: 22
Joined: Wed Oct 20, 2004 2:51 pm
Location: Laurens, SC

Crontab help

Post by davidh »

Thanks to Witness and rony--the poller is now working (I had a typo in my rrdtool path)--sorry I wasted your time on that one.

I have one more issue and then I am up and running. The poller will run only if I issue from command line. The entry in my crontab is not working(will not run automatically).

Here is my complete crontab:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly


*/5****cactiuser /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1

Witness told me in another post to change output from /dev/null. Do I just change to /usr/local/somefile.txt? Do I leave the 2>&1? Thank you so much.

If I issue /www/php/bin/php /www/htdocs/cacti/poller.php from command--poller will work.

David
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Well, I wouldn't run the poller as root, and I wouldn't edit the system crontab.

I would run the poller as another user, for example, cactiuser. To edit the cactiuser crontab I would use, as root:

Code: Select all

crontab -e -u cactiuser
This will allow me to edit the crontab for the cactiuser user. Then I would put the following line in the crontab.

Code: Select all

*/5**** /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
Making sure that the cactiuser has permissions to excute php and to read and write the /www/htdocs/cacti/log and /www/htdocs/cacti/rra directories.

As for logging the output of the poller to a file, well, that is personal choice. I wouldn't as durning a situation where I want see that output, I can simply run the poller manually from the command line and see that output for myself.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
davidh
Posts: 22
Joined: Wed Oct 20, 2004 2:51 pm
Location: Laurens, SC

Post by davidh »

Rory,

Thanks for response--I was out of office all day--I will try tomorrow.
davidh
Posts: 22
Joined: Wed Oct 20, 2004 2:51 pm
Location: Laurens, SC

Post by davidh »

Rony,

Sorry about this--I am new to linux and need to be babied.

To follow your instructions, do I type

crontab -e -u cactiuser in the command line. When I do this,

Here is what I get:

~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/tmp/crontab.XXXX1pO3Gh" 0L, 0C


Does this change me to cactiuser?? I don't know where/how to edit crontab for cactiuser. Thank you for your patience.

David
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

Hi

you can either run "crontab -e -u cactiuser" as root, or "crontab -e" as cactiuser.

If your editor is VI, just type 'i', followed by

Code: Select all

*/5 * * * * /usr/bin/php /www/htdocs/cacti > /dev/null 2>&1
and then quit VI with ":x"
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
john le lardon
Cacti User
Posts: 52
Joined: Fri May 06, 2005 7:39 am
Location: france
Contact:

Post by john le lardon »

you can also assign an other file .
with commande:
crontab -u <user> <path_to_file>/<file_to_use_for_crond>

like this you can use gedit to make a new file for you'r crond (but don't forget line in /etc/crontab !)
i use this methode because my VI don't want save and quit >_< ( error 127 )
davidh
Posts: 22
Joined: Wed Oct 20, 2004 2:51 pm
Location: Laurens, SC

Post by davidh »

I now get this error:

[root@fedora1 ~]# crontab -e -u cactiuser
no crontab for cactiuser - using an empty one
crontab: installing new crontab
"/tmp/crontab.XXXXBGQ7Y7":1: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit? y
crontab: installing new crontab


Any suggestions.

Thanks
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

What are you trying to put in the crontab?
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
davidh
Posts: 22
Joined: Wed Oct 20, 2004 2:51 pm
Location: Laurens, SC

Post by davidh »

Rony,

I am putting

*/5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

Some (old) cron daemons dont know "*/5". Try 0,5,10,15,20,25,30,35,40,45,50,55 instead.
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Code: Select all

*/5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1
Um, what operating system?
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
davidh
Posts: 22
Joined: Wed Oct 20, 2004 2:51 pm
Location: Laurens, SC

Post by davidh »

Sorry,

FC3
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

That should work, make sure you do not have a space in front of the line.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
davidh
Posts: 22
Joined: Wed Oct 20, 2004 2:51 pm
Location: Laurens, SC

Post by davidh »

OK, patience--I still am having problems.

When I am logged in as cactiuser, I type cactiuser -e in terminal, which takes me to vi.
I type 'i', then:

*/5**** /www/php/bin/php /www/htdocs/cacti/poller.php > /dev/null 2>&1


When I attempt to exit I get this error:

"/tmp/crontab.XXXXMZxUlS":1: bad minute
errors in crontab file, can't install.
Do you want to retry the same edit?

I also tried the 0,5,10,15,20,25,30,35,40,45,50,55 and got bad hour.

Again, I know it is something stupid, but I can't see it. Appreciate the help.
john le lardon
Cacti User
Posts: 52
Joined: Fri May 06, 2005 7:39 am
Location: france
Contact:

Post by john le lardon »

do you have try to use my solution? just specify the file of crontab? and using gedit... is the easiest way ...
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests