LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 05-31-2006, 06:38 AM   #1
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Rep: Reputation: 15
Crontab editing


Hi,
I use suse 10.0 and I have some problem with crontab editing. This is what I do:
I use the command
crontab -e
Then I write
32 13 * * * bash /home/.../script_name
Then I save and in crontab list I see my schedule, but at 13:32 anything is done!!
I have the same problem with a different distribution (fedora core 4)
Could someone help me?
 
Old 05-31-2006, 06:57 AM   #2
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
What is your /home/.../script_name supposed to acheive ?
Does it work as expected when you launch the command directly from a terminal ?
Did you check your system mail (with the "mail" command launched as the cron job user) for any possible output ?

Subsidiary question: Why do you prepend "bash" to your script name (and not only the script name with the script being a bash executable) ?
 
Old 05-31-2006, 08:11 AM   #3
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by zeitounator
What is your /home/.../script_name supposed to acheive ?
Does it work as expected when you launch the command directly from a terminal ?
Did you check your system mail (with the "mail" command launched as the cron job user) for any possible output ?

Subsidiary question: Why do you prepend "bash" to your script name (and not only the script name with the script being a bash executable) ?
My script should just open amarok player and play some mp3.
It works well when I launch it from the terminal.
I don't find any mail im my /var/spool/mail when the time of schedule is passed.
If I write
32 12 * * * echo Hello
the cron works well and I find the output in my mail, but it doesn't work with script.
...yes I know there's no need to put "bash" before the script name
 
Old 05-31-2006, 08:46 AM   #4
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
You cannot lauch amarok (nor any other application in need of a running X server) from a cron job. Try to redirect the standard error to some file and you'll probably get the error message that no display was found.

At best, you can try is to load a specific file in an already running instance of amarok but I'm not even sure this is possible if not done from a terminal running on the same display...
 
Old 05-31-2006, 09:07 AM   #5
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by zeitounator
You cannot lauch amarok (nor any other application in need of a running X server) from a cron job. Try to redirect the standard error to some file and you'll probably get the error message that no display was found.

At best, you can try is to load a specific file in an already running instance of amarok but I'm not even sure this is possible if not done from a terminal running on the same display...
ok, but if I make another script that doesn't need display, as an ftp command, it doesn't work the same. What can I do with cron job?
 
Old 05-31-2006, 09:11 AM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Why do you want to play an mp3 from cron?

Sounds like you would at least need a command line mp3 player
 
Old 05-31-2006, 09:11 AM   #7
shshjun
Member
 
Registered: Nov 2004
Location: del
Distribution: jds
Posts: 88

Rep: Reputation: 15
Quote:
Originally Posted by zeitounator
You cannot lauch amarok (nor any other application in need of a running X server) from a cron job. Try to redirect the standard error to some file and you'll probably get the error message that no display was found.
this is not true. general security warning aside about xhost+, i had my morning calls by a song from xmms as cron job 3 years ago.
 
Old 05-31-2006, 09:21 AM   #8
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by billymayday
Why do you want to play an mp3 from cron?

Sounds like you would at least need a command line mp3 player
It was just to make an example, actually I need to execute a scheduled download/upload by ftp. I made a script to do this automatically; it works well if i launch it from terminal but it doesn't work if i put it in a cron job.
 
Old 06-01-2006, 12:33 AM   #9
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
There must be some kind of problem with your script and/or cron file and/or cron daemon and/or cron permissions... Did you try to redirect the output to a file ?

ie:
Code:
32 13 * * * /home/.../script_name 2&> /tmp/scriptoutput.txt
 
Old 06-01-2006, 05:03 AM   #10
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by zeitounator
There must be some kind of problem with your script and/or cron file and/or cron daemon and/or cron permissions... Did you try to redirect the output to a file ?

ie:
Code:
32 13 * * * /home/.../script_name 2&> /tmp/scriptoutput.txt
Yes I tried, for example if I enter the cron job:
Code:
32 13 * * * pppd
I receive the message:
/bin/sh: pppd: command not found.
I tried to enter the command to control if cron service is active and then receive the message:
5011 ? Ss 0:00 /usa/sbin/cron
6876 pts/1 R+ 0:00 grep cron.
What does it mean????
Please help me....
 
Old 06-01-2006, 07:01 AM   #11
zeitounator
Member
 
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262

Rep: Reputation: 30
Hehe I did not dig into cron man page for a while but....

I remember there is something about environment vars which are not the same for the user shell and for the same user using cron.

Here is the illustration as a bash command sequence
Code:
[root@home ~]# echo "44 13 * * * echo \$PATH > /tmp/test" | crontab
[root@home ~]# date
Thu Jun  1 13:43:38 CEST 2006
[root@home ~]# date
Thu Jun  1 13:44:02 CEST 2006
[root@home ~]# more /tmp/test
/usr/bin:/bin
[root@home ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@home ~]# which pppd
/usr/sbin/pppd
[root@home ~]#
So it comes out that /usr/sbin is not in the PATH for root when using cron, which therefore implies a "command not found" on pppd.

Two ways to solve that:
- Set the PATH to the desired value on top of your cron file (i.e. PATH=/bin:/usr/bin:/usr/sbin)
- Give the full path to the script in your cron definition (i.e. /usr/sbin/pppd)
 
Old 06-01-2006, 09:55 AM   #12
chobin
LQ Newbie
 
Registered: May 2006
Location: Italy
Distribution: Fedora Core 4 - Suse 10.0
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by zeitounator
Hehe I did not dig into cron man page for a while but....

I remember there is something about environment vars which are not the same for the user shell and for the same user using cron.

Here is the illustration as a bash command sequence
Code:
[root@home ~]# echo "44 13 * * * echo \$PATH > /tmp/test" | crontab
[root@home ~]# date
Thu Jun  1 13:43:38 CEST 2006
[root@home ~]# date
Thu Jun  1 13:44:02 CEST 2006
[root@home ~]# more /tmp/test
/usr/bin:/bin
[root@home ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@home ~]# which pppd
/usr/sbin/pppd
[root@home ~]#
So it comes out that /usr/sbin is not in the PATH for root when using cron, which therefore implies a "command not found" on pppd.

Two ways to solve that:
- Set the PATH to the desired value on top of your cron file (i.e. PATH=/bin:/usr/bin:/usr/sbin)
- Give the full path to the script in your cron definition (i.e. /usr/sbin/pppd)
I DID IT!!!!!!
I just needed to restart cron service after editing it with the command
Code:
/etc/init.d/cron restart
Thank you very much for your help
 
Old 06-01-2006, 10:12 AM   #13
shshjun
Member
 
Registered: Nov 2004
Location: del
Distribution: jds
Posts: 88

Rep: Reputation: 15
thank you, chobin, to share your solution (and excitement).
i think i will benifit from your post here later...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
editing crontab mfran2002 Linux - Software 2 02-20-2006 07:09 AM
BASH :Reading the crontab, and editing it semaja2 Programming 4 02-05-2006 06:43 AM
editing crontab djgerbavore Slackware 12 05-30-2005 09:24 PM
Crontab wormraper Debian 4 05-15-2005 01:01 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 10:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration