I am doing this little experiment in cron, but not able to make it work.
I want cron to play a certain mp3 file at a certain time. So I add the usual time parameters and add the following to the command field: /usr/bin/ffplay <path to my mp3 file>
But cron mails me an error which I have attached as text file.
I also tried "/bin/bash /usr/bin/ffplay <path to my mp3 file>" but it does not work.
Where am I going wrong?
When I simply give the following command from terminal, it plays the file: ffplay <mp3 file>
On Mon, Sep 20, 2010 at 11:49:48PM +0530, Nitesh Mistry wrote:
I am doing this little experiment in cron, but not able to make it work.
I want cron to play a certain mp3 file at a certain time. So I add the usual time parameters and add the following to the command field: /usr/bin/ffplay <path to my mp3 file>
But cron mails me an error which I have attached as text file.
I also tried "/bin/bash /usr/bin/ffplay <path to my mp3 file>" but it does not work.
Where am I going wrong?
When I simply give the following command from terminal, it plays the file: ffplay <mp3 file>
-- Regards, Nitesh Mistry www.mistrynitesh.com PGP key id: CC580416
FFplay version 0.5-svn17737+3:0.svn20090303-1ubuntu6.2, Copyright (c) 2003-2009 Fabrice Bellard, et al. configuration: --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --extra-version=svn17737+3:0.svn20090303-1ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --disable-stripping --disable-vhook --enable-libdc1394 --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-armvfp --disable-neon --disable-altivec --disable-vis --enable-shared --disable-static libavutil 49.15. 0 / 49.15. 0 libavcodec 52.20. 0 / 52.20. 0 libavformat 52.31. 0 / 52.31. 0 libavdevice 52. 1. 0 / 52. 1. 0 libavfilter 0. 4. 0 / 0. 4. 0 libswscale 0. 7. 1 / 0. 7. 1 libpostproc 51. 2. 0 / 51. 2. 0 built on Apr 23 2010 15:08:34, gcc: 4.3.3
=======================| DirectFB 1.0.1 |======================= (c) 2001-2007 The DirectFB Organization (directfb.org) (c) 2000-2004 Convergence (integrated media) GmbH ------------------------------------------------------------
(*) DirectFB/Core: Single Application Core. (2008-11-12 15:27) (!) Direct/Util: opening '/dev/fb0' and '/dev/fb/0' failed --> No such file or directory (!) DirectFB/FBDev: Error opening framebuffer device! (!) DirectFB/FBDev: Use 'fbdev' option or set FRAMEBUFFER environment variable. (!) DirectFB/Core: Could not initialize 'system' core! --> Initialization error! Could not initialize SDL - DirectFBCreate: Initialization error!
This seems to a problem with ffplay. It worked fine with cvlc. Sorry to bother all you people.
But there is one more thing. Cron executes the 'fetchmail' command listed in my crontab list irrespective of whether I am logged in or not. But it executes the vlc command only if I am logged in.
Is there any way I can make cron play the song (either with vlc or any other program) even without me being logged in?
On Tuesday 21 September 2010 12:16:03 am Nitesh Mistry wrote:
On Mon, Sep 20, 2010 at 11:49:48PM +0530, Nitesh Mistry wrote:
I am doing this little experiment in cron, but not able to make it work.
I want cron to play a certain mp3 file at a certain time. So I add the usual time parameters and add the following to the command field: /usr/bin/ffplay <path to my mp3 file>
But cron mails me an error which I have attached as text file.
I also tried "/bin/bash /usr/bin/ffplay <path to my mp3 file>" but it does not work.
Where am I going wrong?
When I simply give the following command from terminal, it plays the file: ffplay <mp3 file>
FFplay version 0.5-svn17737+3:0.svn20090303-1ubuntu6.2, Copyright (c) 2003-2009 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --extra-version=svn17737+3:0.svn20090303-1ubuntu6.2 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --disable-stripping --disable-vhook --enable-libdc1394 --disable-armv5te --disable-armv6 --disable-armv6t2 --disable-armvfp --disable-neon --disable-altivec --disable-vis --enable-shared --disable-static libavutil 49.15. 0 / 49.15. 0 libavcodec 52.20. 0 / 52.20. 0 libavformat 52.31. 0 / 52.31. 0 libavdevice 52. 1. 0 / 52. 1. 0 libavfilter 0. 4. 0 / 0. 4. 0 libswscale 0. 7. 1 / 0. 7. 1 libpostproc 51. 2. 0 / 51. 2. 0 built on Apr 23 2010 15:08:34, gcc: 4.3.3
=======================| DirectFB 1.0.1 |======================= (c) 2001-2007 The DirectFB Organization (directfb.org) (c) 2000-2004 Convergence (integrated media) GmbH ------------------------------------------------------------
(*) DirectFB/Core: Single Application Core. (2008-11-12 15:27) (!) Direct/Util: opening '/dev/fb0' and '/dev/fb/0' failed
--> No such file or directory
(!) DirectFB/FBDev: Error opening framebuffer device! (!) DirectFB/FBDev: Use 'fbdev' option or set FRAMEBUFFER environment variable. (!) DirectFB/Core: Could not initialize 'system' core!
--> Initialization error!
Could not initialize SDL - DirectFBCreate: Initialization error!
This seems to a problem with ffplay. It worked fine with cvlc. Sorry to bother all you people.
But there is one more thing. Cron executes the 'fetchmail' command listed in my crontab list irrespective of whether I am logged in or not. But it executes the vlc command only if I am logged in.
Is there any way I can make cron play the song (either with vlc or any other program) even without me being logged in?
<stupid, easy, security issue, solution> run it as root?
On Tuesday 21 September 2010 12:35 AM, Yohan Pereira wrote:
<stupid, easy, security issue, solution> run it as root?
Hi. Please trim your message. For a one line reply, an entire A4 page sized text was used up.
On Tue, Sep 21, 2010 at 12:35:57AM +0530, Yohan Pereira wrote:
But there is one more thing. Cron executes the 'fetchmail' command listed in my crontab list irrespective of whether I am logged in or not. But it executes the vlc command only if I am logged in.
Is there any way I can make cron play the song (either with vlc or any other program) even without me being logged in?
<stupid, easy, security issue, solution> run it as root?
Either that or setup auto log-in - which is the better of the two devils?
On Tuesday 21 September 2010 10:53 PM, Nitesh Mistry wrote:
<stupid, easy, security issue, solution> run it as root?
Either that or setup auto log-in - which is the better of the two devils?
How about running the script as root but inside the script, do a 'su -user'. Root will not be asked for user password and the player runs as user.
On Mon, Sep 20, 2010 at 11:49:48PM +0530, Nitesh Mistry wrote:
I am doing this little experiment in cron, but not able to make it work.
I want cron to play a certain mp3 file at a certain time. So I add the usual time parameters and add the following to the command field: /usr/bin/ffplay <path to my mp3 file>
But cron mails me an error which I have attached as text file.
I also tried "/bin/bash /usr/bin/ffplay <path to my mp3 file>" but it does not work.
Where am I going wrong?
you are trying executing (via cron) a Graphical program without a display.environment.
When I simply give the following command from terminal, it plays the file: ffplay <mp3 file>
Try a command line player like mplayer or cvlc
cvlc file:///<path to your mp3 file>
--> Initialization error! Could not initialize SDL - DirectFBCreate: Initialization error!
cron is not associated with any X session.
This seems to a problem with ffplay. It worked fine with cvlc. Sorry to bother all you people.
Not at all. Experimentation is a great way to learn how Linux works.
But there is one more thing. Cron executes the 'fetchmail' command listed in my crontab list irrespective of whether I am logged in or not. But it
fetchmail does not need access to any special devices like audio/video applications.
executes the vlc command only if I am logged in.
What is the error message from cron?
-- Arun Khan
On Tue, Sep 21, 2010 at 01:36:50AM +0530, Arun Khan wrote:
But there is one more thing. Cron executes the 'fetchmail' command listed in my crontab list irrespective of whether I am logged in or not. But it
fetchmail does not need access to any special devices like audio/video applications.
executes the vlc command only if I am logged in.
What is the error message from cron?
When I am not logged in, cron still executes the command (as I can see from the syslog) but there is no output. And no message from cron for this instance.
Whereas, when I am logged in, the song is played but I also get a message (attached) from the cron.
On Tuesday 21 September 2010 10:49 PM, Nitesh Mistry wrote:
When I am not logged in, cron still executes the command (as I can see from the syslog) but there is no output. And no message from cron for this instance.
Whereas, when I am logged in, the song is played but I also get a message (attached) from the cron.
See if this link helps.
http://www.linuxquestions.org/questions/linux-general-1/background-mplayer-f...
On Tue, Sep 21, 2010 at 10:57:11PM +0530, Rony wrote:
On Tuesday 21 September 2010 10:49 PM, Nitesh Mistry wrote:
When I am not logged in, cron still executes the command (as I can see from the syslog) but there is no output. And no message from cron for this instance.
Whereas, when I am logged in, the song is played but I also get a message (attached) from the cron.
See if this link helps.
http://www.linuxquestions.org/questions/linux-general-1/background-mplayer-f...
Thanks for the link. But the answers there still requires the user to log in to a console, and that is where I am stuck.
On Tue, Sep 21, 2010 at 10:08 PM, Nitesh Mistry mailbox@mistrynitesh.net wrote:
On Tue, Sep 21, 2010 at 10:57:11PM +0530, Rony wrote:
On Tuesday 21 September 2010 10:49 PM, Nitesh Mistry wrote:
When I am not logged in, cron still executes the command (as I can see from the syslog) but there is no output. And no message from cron for this instance.
While logged in to your console, where manually typing the command works, type "env" to get your environment. Copy this to a blank file and append the mp3 command after it. chmod this file to have execute permissions, and add a shebang line.
This should work as long as you have the X server running. You would need the DISPLAY variable set. Something like export DISPLAY=localhost:0.0
Regards, NMK.
On 09/21/2010 10:49 PM, Nitesh Mistry wrote:
On Tue, Sep 21, 2010 at 01:36:50AM +0530, Arun Khan wrote: [...snip...] When I am not logged in, cron still executes the command (as I can see from the syslog) but there is no output. And no message from cron for this instance.
Whereas, when I am logged in, the song is played but I also get a message (attached) from the cron.
From the error message ...
libdvdread: Can't stat /media/newdisk/songs/Silk Route - Boondein/01 - Boondein.ogg No such file or directory [00000419] access_directory access error: /media/newdisk/songs/Silk Route - Boondein/01 - Boondein.ogg: No such file or directory [00000419] access_file access error: cannot open file /media/newdisk/songs/Silk Route - Boondein/01 - Boondein.ogg (No such file or directory) [00000413] main input error: open of `/media/newdisk/songs/Silk Route - Boondein/01 - Boondein.ogg' failed: could not create access: no suitable access module [00000402] signals interface error: Caught Terminated signal, exiting... libdvdnav: Using dvdnav version 4.1.3 libdvdnav: vm: failed to open/read the DVD
...it looks like the reason it fails is because vlc can't access the DVD. Judging by the path I guess the DVD is automounted when you are logged in. I'd suggest modifying your script to mount your media before attempting to play.
btw, did you google[1] before attempting your experiment ? This is fairly common thing almost all of us attempt at some point or the other. In the early days when linux was not so ^user-friendly^, these hacks were easier to do :-)
cheers, - steve
Look only if you /want/ step-by-step instructions, if you want to discover the way to achieve it by trial-n-error don't click: http://www.google.com/search?q=linux+cron+music+alarm
On Wed, Sep 22, 2010 at 12:07:22AM +0530, steve wrote:
Look only if you /want/ step-by-step instructions, if you want to discover the way to achieve it by trial-n-error don't click: http://www.google.com/search?q=linux+cron+music+alarm
I am in no mood for clicking. :D
On Wednesday 22 September 2010 12:20 PM, Nitesh Mistry wrote:
On Wed, Sep 22, 2010 at 12:07:22AM +0530, steve wrote:
Look only if you /want/ step-by-step instructions, if you want to discover the way to achieve it by trial-n-error don't click: http://www.google.com/search?q=linux+cron+music+alarm
I am in no mood for clicking. :D
I downloaded 'mpg123' from apt and created an executable script to run 'mpg123 song.mp3' and the script worked fine. Then I added it to the user cron job but it did not play without login. However the same script plays the song with the root's cron job without login. So if you don't have any allergy :-) towards running the script as root, the system works.
I did the experiment as I have been wanting to add bells and whistles to a headless ( no monitor and keyboard ) server for making announcements on a small speaker.
On Wed, Sep 22, 2010 at 08:42:01PM +0530, Rony wrote:
I downloaded 'mpg123' from apt and created an executable script to run 'mpg123 song.mp3' and the script worked fine. Then I added it to the user cron job but it did not play without login. However the same script plays the song with the root's cron job without login. So if you don't have any allergy :-) towards running the script as root, the system works.
MPG123!!! That solved my issue. The problem was that I was using wrong program (cvlc, ffplay, etc) for the task at hand.
AND with mpg123, I don't need to run it with sudo or in root's cron. Simply adding 'mpg123 <song.mp3>' to my user's cron works even when I am not logged in.
The only drawback that I see with this is that mpg123 does not play my .ogg files.
Thanks all of you!
Hi,
On 09/23/2010 03:29 PM, Nitesh Mistry wrote:
On Wed, Sep 22, 2010 at 08:42:01PM +0530, Rony wrote:
I downloaded 'mpg123' from apt and created an executable script to run 'mpg123 song.mp3' and the script worked fine. Then I added it to the user cron job but it did not play without login. However the same script plays the song with the root's cron job without login. So if you don't have any allergy :-) towards running the script as root, the system works.
MPG123!!! That solved my issue. The problem was that I was using wrong program (cvlc, ffplay, etc) for the task at hand.
AND with mpg123, I don't need to run it with sudo or in root's cron. Simply adding 'mpg123<song.mp3>' to my user's cron works even when I am not logged in.
The only drawback that I see with this is that mpg123 does not play my .ogg files.
How about ogg123 ? You might then want to script using the right player for depending on the file type.
Thanks all of you!
Congrats :). Maybe you'd want to blog about your experiment.
cheers, - steve
On Thu, Sep 23, 2010 at 03:45:44PM +0530, steve wrote:
The only drawback that I see with this is that mpg123 does not play my .ogg files.
How about ogg123 ? You might then want to script using the right player for depending on the file type.
Thanks for the tip
Thanks all of you!
Congrats :). Maybe you'd want to blog about your experiment.
I am already on it :D Will post the link as soon as I am done.
On Thu, Sep 23, 2010 at 04:01:09PM +0530, Nitesh Mistry wrote:
On Thu, Sep 23, 2010 at 03:45:44PM +0530, steve wrote:
The only drawback that I see with this is that mpg123 does not play my .ogg files.
How about ogg123 ? You might then want to script using the right player for depending on the file type.
Thanks for the tip
Thanks all of you!
Congrats :). Maybe you'd want to blog about your experiment.
I am already on it :D Will post the link as soon as I am done.
Here is the link to the blog post: http://www.mistrynitesh.com/blog/Computer_as_an_Alarm_Clock_.html
On Thu, Sep 23, 2010 at 3:45 PM, steve steve@lonetwin.net wrote:
On 09/23/2010 03:29 PM, Nitesh Mistry wrote:
The only drawback that I see with this is that mpg123 does not play my .ogg files.
How about ogg123 ? You might then want to script using the right player for depending on the file type.
How about using mplayer or cvlc as others suggested before? They will handle all audio formats. They can play video formats too as long as you give it the right parameters to not use X to display the video.
On Thursday 23 September 2010 03:29 PM, Nitesh Mistry wrote:
AND with mpg123, I don't need to run it with sudo or in root's cron. Simply adding 'mpg123<song.mp3>' to my user's cron works even when I am not logged in.
Great. I tried it again in user but I still need to be logged in to at least one session, console or gui. The funny part is that if I log out, the song stops there and continues after I log in again.
On Friday 24 September 2010 7:26:40 am Rony wrote:
Great. I tried it again in user but I still need to be logged in to at least one session, console or gui. The funny part is that if I log out, the song stops there and continues after I log in again.
i think this is probably because of pulse audio .. are you running that?
On Friday 24 September 2010 10:12 AM, Yohan Pereira wrote:
On Friday 24 September 2010 7:26:40 am Rony wrote:
Great. I tried it again in user but I still need to be logged in to at least one session, console or gui. The funny part is that if I log out, the song stops there and continues after I log in again.
i think this is probably because of pulse audio .. are you running that?
Yes. I think it is the permission thing that Rajeev has mentioned.
On Friday 24 September 2010 7:47:05 pm Rony wrote:
Yes. I think it is the permission thing that Rajeev has mentioned.
Probably .. but why would it continue? woudnt it just quit with an error msg the first time?
when i used pulseaudio(ubuntu) it used to do stuff like say your listening to music, and you switch to another user (or a tty logged in as another user for that matter) it would mute the output stream from the music player, and continue when you switch back.
On Friday 24 September 2010 10:00 PM, Yohan Pereira wrote:
On Friday 24 September 2010 7:47:05 pm Rony wrote:
Yes. I think it is the permission thing that Rajeev has mentioned.
Probably .. but why would it continue? woudnt it just quit with an error msg the first time?
The user is part of the audio group and has permission to use sound. However the login is necessary. A simple solution would be to add some lines in the script to login into a shell and then play the music as user.
when i used pulseaudio(ubuntu) it used to do stuff like say your listening to music, and you switch to another user (or a tty logged in as another user for that matter) it would mute the output stream from the music player, and continue when you switch back.
What I noticed was that when I was playing a song on youtube and the cron job coincided with it and I was hearing 2 different songs playing together. My system Ubuntu 10.04.
On Friday 24 September 2010 07:26:40 Rony wrote:
On Thursday 23 September 2010 03:29 PM, Nitesh Mistry wrote:
AND with mpg123, I don't need to run it with sudo or in root's cron. Simply adding 'mpg123<song.mp3>' to my user's cron works even when I am not logged in.
sox <options to generate raw> >/dev/dsp0 will render audio of all sorts without any fuss.
On Fri, Sep 24, 2010 at 7:26 AM, Rony gnulinuxist@gmail.com wrote:
On Thursday 23 September 2010 03:29 PM, Nitesh Mistry wrote:
AND with mpg123, I don't need to run it with sudo or in root's cron. Simply adding 'mpg123<song.mp3>' to my user's cron works even when I am not logged in.
Great. I tried it again in user but I still need to be logged in to at least one session, console or gui. The funny part is that if I log out, the song stops there and continues after I log in again.
Hiya all
I think the culprit here is the permissions system. Usually, Systems like PackageKit assign permissions to various devices to allow normal user access without having to manually add users to various groups. If you remember the good old days, we used to add users to the 'audio' group to allow them to play audio, and to the 'tty' group to allow them to access serial ports, etc. On Modern distro's when a user logs in, the permissions of the relevant devices are updated to allow that user to access it, using filesystem ACL's. That way, as long as your login is at a local console, you get access to all physically connected hardware IO devices, subject to certian rules..
This is why your programs are playing audio as long as you are logged in somewhere or the other, but refuse to play when you are logged out. It's nothing but a simple permission denied issue.
The quickest solution to this would be to use root's crontab, but that will make any self-respecting sysadmin want to shoot you in the head :) The other option is to modify your Udev config to create all audio devices with the appropriate permissions so that your user who runs the cron jobs is given access to the device by default, without waiting for the login process to grant access. For example, on Fedora, modifying the '/lib/udev/rules.d/40-alsa.rules' or the '/etc/udev/rules.d/90-alsa.rules' should allow you to create the appropriate ACL Entries automatically, so that audio device acccess is never denied to the said user.
Once this is done, you can use any tool that takes your fancy(mplayer, cvlc, mpg123, mpg321, ogg123, madplay, aplay, sox( the granddaddy of tyem all)), and it sould work fine. My personal prefference though is mplayer, since it handles anything i throw at it, and when i play in a GUI environment, it allows me to use vdpau on my GPU.
Hope this helps.
Regards R. K. Rajeev
--
As a proper list etiquette... Please trim your replies. Post your replies below the relevant original text, leaving a line space. Do not re-use old messages to write new ones.
Regards,
Rony.
On Friday 24 September 2010 11:59 AM, Rajeev R. K. wrote:
I think the culprit here is the permissions system. Usually, Systems like PackageKit assign permissions to various devices to allow normal user access without having to manually add users to various groups. If you remember the good old days, we used to add users to the 'audio' group to allow them to play audio, and to the 'tty' group to allow them to access serial ports, etc. On Modern distro's when a user logs in, the permissions of the relevant devices are updated to allow that user to access it, using filesystem ACL's. That way, as long as your login is at a local console, you get access to all physically connected hardware IO devices, subject to certian rules..
This is why your programs are playing audio as long as you are logged in somewhere or the other, but refuse to play when you are logged out. It's nothing but a simple permission denied issue.
I agree. This is also one reason why 'audacity' is good at editing audio files but bad at recording live from audio input jacks in user mode. It does not give access of the sound devices to the user, even when logged in. The sound recorded is blank.
On Fri, Sep 24, 2010 at 07:26:40AM +0530, Rony wrote:
On Thursday 23 September 2010 03:29 PM, Nitesh Mistry wrote:
AND with mpg123, I don't need to run it with sudo or in root's cron. Simply adding 'mpg123<song.mp3>' to my user's cron works even when I am not logged in.
Great. I tried it again in user but I still need to be logged in to at least one session, console or gui. The funny part is that if I log out, the song stops there and continues after I log in again.
Hmm, I think I have screwed my OS good enough to let user cron run even when not logged in.
Guess I should try it on a fresh install.
:D
On Fri, Sep 24, 2010 at 07:26:40AM +0530, Rony wrote:
On Thursday 23 September 2010 03:29 PM, Nitesh Mistry wrote:
AND with mpg123, I don't need to run it with sudo or in root's cron. Simply adding 'mpg123<song.mp3>' to my user's cron works even when I am not logged in.
Great. I tried it again in user but I still need to be logged in to at least one session, console or gui. The funny part is that if I log out, the song stops there and continues after I log in again.
My bad. It was a bit of laziness in testing it properly or should I say my ignorance of the difference between a fresh reboot and a simple logging out of the session.
When I said *it worked*, it did work, but at that time, I had just logged out of my session (not logged in to the computer anywhere else). So I assumed that it would be same state as if I had just rebooted the computer and no one logged in yet. But as I discovered, its not the same.
So yes, the command will have to be given in root's cron to work after a fresh reboot.
Sorry for creating confusion. Next time, will bear in mind to test properly. Also updated my blog post [0] accordingly.
Its amazing how much you discover when you do the stuff yourself instead of just following 'how-tos' from the web.
[0] http://www.mistrynitesh.com/blog/Computer_as_an_Alarm_Clock_.html
On Saturday 25 September 2010 11:50 AM, Nitesh Mistry wrote:
Sorry for creating confusion. Next time, will bear in mind to test properly. Also updated my blog post [0] accordingly.
Its amazing how much you discover when you do the stuff yourself instead of just following 'how-tos' from the web.
You did not create any confusion. Your report made me retrace my steps to reconfirm and mine helped you retrace yours. :-) Learning is fun.
2010/9/21 Nitesh Mistry mailbox@mistrynitesh.net:
When I am not logged in, cron still executes the command (as I can see from the syslog) but there is no output. And no message from cron for this instance.
normally, cron would mail you the output of the run. check that user's mail.
Anurag
On Monday 20 Sep 2010, Nitesh Mistry wrote:
I want cron to play a certain mp3 file at a certain time. So I add the usual time parameters and add the following to the command field: /usr/bin/ffplay <path to my mp3 file>
But cron mails me an error which I have attached as text file.
ffplay appears to require a working X to function, and jobs run through cron will not have access to your X display (if any is running). You may be better off using a console-only MP3 player for this.
Regards,
-- Raj
On Monday 20 September 2010 11:49 PM, Nitesh Mistry wrote:
I am doing this little experiment in cron, but not able to make it work.
I want cron to play a certain mp3 file at a certain time. So I add the usual time parameters and add the following to the command field: /usr/bin/ffplay<path to my mp3 file>
To make life simpler, for all cron jobs, use an executable script file, don't give commands inside the cron table. For your experiment use only command line terminals. Don't log into your gui account. If your script file works using './path/script_file' then it will work inside cron too.