SUSE / openSUSEThis Forum is for the discussion of Suse Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
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) ?
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
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
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...
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?
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.
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.
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
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 ?
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 ?
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....
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
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)
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.