crontab does not work

Asked by jacek

I am testing crontab on Ubuntu 8.04 and I can not get it to work at all. i have tried the manual at: https://help.ubuntu.com/community/CronHowto but still no luck

I set my cron about two minutes ahead with the following parameters by using crontab -e and also sudo crontab -e and nothing works but the crontab installs fine as it gives no errors. please advice how I can get this to work

# m h dom mon dow command
PATH=/usr/sbin:/usr/bin:/sbin:/bin
44 19 * * * /usr/bin/firefox
44 07 * * * /usr/bin/firefox

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu cron Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Luky Winarto (luckyborneo) said :
#1

Hi jacek,

Have you ever see the cron log? Try this command to see it:
$ sudo grep CRON /var/log/syslog

Let see if your crontab script didn't work.

-Luky-0000000

Revision history for this message
jacek (jacekb57) said :
#2

Hey Lucky,

I am not sure but I do not think that it did, can you adviceL

-desktop:~$ sudo grep CRON /var/log/syslog
Aug 7 15:17:01 jacekb01-desktop /USR/SBIN/CRON[6944]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 7 16:17:01 jacekb01-desktop /USR/SBIN/CRON[7667]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 7 18:46:03 jacekb01-desktop /usr/sbin/cron[5398]: (CRON) INFO (pidfile fd = 3)
Aug 7 18:46:03 jacekb01-desktop /usr/sbin/cron[5402]: (CRON) STARTUP (fork ok)
Aug 7 18:46:03 jacekb01-desktop /usr/sbin/cron[5402]: (CRON) INFO (Running @reboot jobs)
Aug 7 19:17:01 jacekb01-desktop /USR/SBIN/CRON[6111]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 7 19:44:01 jacekb01-desktop /USR/SBIN/CRON[6182]: (root) CMD (/usr/bin/firefox)
Aug 7 20:17:01 jacekb01-desktop /USR/SBIN/CRON[6197]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 7 21:17:01 jacekb01-desktop /USR/SBIN/CRON[6280]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 7 22:17:01 jacekb01-desktop /USR/SBIN/CRON[6499]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 7 23:17:01 jacekb01-desktop /USR/SBIN/CRON[6650]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 8 05:10:20 jacekb01-desktop /usr/sbin/cron[5392]: (CRON) INFO (pidfile fd = 3)
Aug 8 05:10:20 jacekb01-desktop /usr/sbin/cron[5393]: (CRON) STARTUP (fork ok)
Aug 8 05:10:20 jacekb01-desktop /usr/sbin/cron[5393]: (CRON) INFO (Running @reboot jobs)
Aug 8 05:17:01 jacekb01-desktop /USR/SBIN/CRON[5851]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Aug 8 08:31:53 jacekb01-desktop /usr/sbin/cron[5424]: (CRON) INFO (pidfile fd = 3)
Aug 8 08:31:53 jacekb01-desktop /usr/sbin/cron[5425]: (CRON) STARTUP (fork ok)
Aug 8 08:31:53 jacekb01-desktop /usr/sbin/cron[5425]: (CRON) INFO (Running @reboot jobs)
jacekb01@jacekb01-desktop:~$

Revision history for this message
Arnaud Soyez (weboide) said :
#3

Jacek,

It seems to work well, see:
Aug 7 19:44:01 jacekb01-desktop /USR/SBIN/CRON[6182]: (root) CMD (/usr/bin/firefox)

Note that you will not firefox run because:
- It is being run as root, your user maybe different.
- Root might have a current display
- cron doesn't pass environment variables like DISPLAY.

If you just wish to start firefox at a precise date and only once, I suggest you look at "at":

$ at now + 1 min
warning: commands will be executed using /bin/sh
at> firefox
at> <EOT> (I pushed ctrl+D)
job 7 at Sat Aug 8 15:59:00 2009

Revision history for this message
Arnaud Soyez (weboide) said :
#4

I forgot to add the DISPLAY variable:

at> DISPLAY=":0.0" firefox

Revision history for this message
jacek (jacekb57) said :
#5

hi Arnaud,

but when i set cron as the user, firefox never opened. since it worked in root i gues the syntax is right. any ideas?

Revision history for this message
Arnaud Soyez (weboide) said :
#6

I got it working on my Ubuntu this way:

I'm logged in as a regular user (non-root).

1) Open a terminal
2) type "crontab -e"
3) I add this line:
*/2 * * * * DISPLAY=":0.0" firefox
4) type ":wq" to save and quit vim (depends on your default editor)
5) It will say "crontab: installing new crontab"
6) Then every two minutes, it will open a firefox instance.

Can you help with this problem?

Provide an answer of your own, or ask jacek for more information if necessary.

To post a message you must log in.