Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
I run Ubuntu 6.06 with linux kernel 2.6.15-27-386 on an IBM Thinkpad laptop.
Here is my question: I want to schedule recordings of internet audio streams (public radio) and automatically convert them to mp3 files for my ipod. I use mplayer to dump the audio stream into a ram file. Then I use mplayer again to convert the ram file to a wav file. Then lame to convert the wav file to a mp3 file.
All of this works without a hitch except the step from ram to wav. The odd thing is that this can easily be done on the command line:
The result is a wav file which is interrupted after ten seconds. You always hear the first ten seconds, no matter how long the original file is, and then nothing.
What could it possibly be about this command running in cron that doesn't make it work, as opposed to running it on the command line?
Remember cron doesn't inherit environment. When you login you create an environment because you get /etc/profile, /etc/bashrc, $HOME/.profile, $HOME/.bashrc and any other sourced file. You also run a full shell (typically bash on Linux). Cron runs a simple shell and does not source all these files.
It may be that this isn't working because it is relying on some environment variable that isn't there when you run it in cron.
You could try putting it in a script that includes the shell and any of the environment variables that you have at command line (even just sourcing them).
Also remember you have a display device attached when you are logged in but cron has no output device. You might want to make sure you add redirect to /dev/null at end of your cron entry:
>/dev/null 2>&1
So your script should start with the shell you want:
#!/bin/bash
You could then set the variables or you could source in the same files you do when you login:
. /etc/profile
. /etc/bash
. <full path to user home>/.profile
. <full path to user home>/.bashrc
then after all that add your command line. In cron you would then tell it to run the script rather than the command. You also put the redirection to /dev/null mentioned above.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.