Script doesn't run via crontab but works fine standalone












47














I have a script that reminds me to restart my computer if uptime is more than, say 3 days (although its set to 0 days now just to check if the script is running as my computer has been up only over a day..).



I realize it isn't the most elegant script but I am trying! :)



#!/bin/bash

up=$(uptime | grep "day" > /home/username/uptime.foo && awk < /home/username/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"


I have made it executable by chmod + x checkup.sh and it works fine when I run it fro the terminal via ./checkup.sh



My crontab entry for this script is:



46 14 * * * /home/username/Desktop/./checkup.sh



So it runs at 14:46hrs daily...



So... I am thinking it should run, unless I didn't something really silly.
Also, do you think it's ok to move this bash script to /bin?










share|improve this question




















  • 1




    I would put it in /opt/bin or ~/bin as a general best practice to not muck up where packages think things are.
    – RobotHumans
    Apr 1 '12 at 18:55












  • If you run the script like so: /home/dnaneet/Desktop/./checkup.sh does it work? I would put /home/dnaneet/Desktop/checkup.sh
    – LnxSlck
    Apr 1 '12 at 18:59










  • @LnxSlck Yes, running /home/dnaneet/Desktop/./checkup.sh works fine. But /home/dnaneet/Desktop/checkup.sh may not work right? Because it needs a ./?
    – drN
    Apr 1 '12 at 19:03






  • 1




    I don't think cron knows anything about your X session.
    – glenn jackman
    Apr 1 '12 at 19:34










  • @glennjackman So what does that mean? Does it mean that running such a script through crontab doesn't allow a pop up message to show up in the gnome environment?
    – drN
    Apr 1 '12 at 19:38
















47














I have a script that reminds me to restart my computer if uptime is more than, say 3 days (although its set to 0 days now just to check if the script is running as my computer has been up only over a day..).



I realize it isn't the most elegant script but I am trying! :)



#!/bin/bash

up=$(uptime | grep "day" > /home/username/uptime.foo && awk < /home/username/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"


I have made it executable by chmod + x checkup.sh and it works fine when I run it fro the terminal via ./checkup.sh



My crontab entry for this script is:



46 14 * * * /home/username/Desktop/./checkup.sh



So it runs at 14:46hrs daily...



So... I am thinking it should run, unless I didn't something really silly.
Also, do you think it's ok to move this bash script to /bin?










share|improve this question




















  • 1




    I would put it in /opt/bin or ~/bin as a general best practice to not muck up where packages think things are.
    – RobotHumans
    Apr 1 '12 at 18:55












  • If you run the script like so: /home/dnaneet/Desktop/./checkup.sh does it work? I would put /home/dnaneet/Desktop/checkup.sh
    – LnxSlck
    Apr 1 '12 at 18:59










  • @LnxSlck Yes, running /home/dnaneet/Desktop/./checkup.sh works fine. But /home/dnaneet/Desktop/checkup.sh may not work right? Because it needs a ./?
    – drN
    Apr 1 '12 at 19:03






  • 1




    I don't think cron knows anything about your X session.
    – glenn jackman
    Apr 1 '12 at 19:34










  • @glennjackman So what does that mean? Does it mean that running such a script through crontab doesn't allow a pop up message to show up in the gnome environment?
    – drN
    Apr 1 '12 at 19:38














47












47








47


18





I have a script that reminds me to restart my computer if uptime is more than, say 3 days (although its set to 0 days now just to check if the script is running as my computer has been up only over a day..).



I realize it isn't the most elegant script but I am trying! :)



#!/bin/bash

up=$(uptime | grep "day" > /home/username/uptime.foo && awk < /home/username/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"


I have made it executable by chmod + x checkup.sh and it works fine when I run it fro the terminal via ./checkup.sh



My crontab entry for this script is:



46 14 * * * /home/username/Desktop/./checkup.sh



So it runs at 14:46hrs daily...



So... I am thinking it should run, unless I didn't something really silly.
Also, do you think it's ok to move this bash script to /bin?










share|improve this question















I have a script that reminds me to restart my computer if uptime is more than, say 3 days (although its set to 0 days now just to check if the script is running as my computer has been up only over a day..).



I realize it isn't the most elegant script but I am trying! :)



#!/bin/bash

up=$(uptime | grep "day" > /home/username/uptime.foo && awk < /home/username/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"


I have made it executable by chmod + x checkup.sh and it works fine when I run it fro the terminal via ./checkup.sh



My crontab entry for this script is:



46 14 * * * /home/username/Desktop/./checkup.sh



So it runs at 14:46hrs daily...



So... I am thinking it should run, unless I didn't something really silly.
Also, do you think it's ok to move this bash script to /bin?







cron






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 9 at 21:03

























asked Apr 1 '12 at 18:52









drN

99651427




99651427








  • 1




    I would put it in /opt/bin or ~/bin as a general best practice to not muck up where packages think things are.
    – RobotHumans
    Apr 1 '12 at 18:55












  • If you run the script like so: /home/dnaneet/Desktop/./checkup.sh does it work? I would put /home/dnaneet/Desktop/checkup.sh
    – LnxSlck
    Apr 1 '12 at 18:59










  • @LnxSlck Yes, running /home/dnaneet/Desktop/./checkup.sh works fine. But /home/dnaneet/Desktop/checkup.sh may not work right? Because it needs a ./?
    – drN
    Apr 1 '12 at 19:03






  • 1




    I don't think cron knows anything about your X session.
    – glenn jackman
    Apr 1 '12 at 19:34










  • @glennjackman So what does that mean? Does it mean that running such a script through crontab doesn't allow a pop up message to show up in the gnome environment?
    – drN
    Apr 1 '12 at 19:38














  • 1




    I would put it in /opt/bin or ~/bin as a general best practice to not muck up where packages think things are.
    – RobotHumans
    Apr 1 '12 at 18:55












  • If you run the script like so: /home/dnaneet/Desktop/./checkup.sh does it work? I would put /home/dnaneet/Desktop/checkup.sh
    – LnxSlck
    Apr 1 '12 at 18:59










  • @LnxSlck Yes, running /home/dnaneet/Desktop/./checkup.sh works fine. But /home/dnaneet/Desktop/checkup.sh may not work right? Because it needs a ./?
    – drN
    Apr 1 '12 at 19:03






  • 1




    I don't think cron knows anything about your X session.
    – glenn jackman
    Apr 1 '12 at 19:34










  • @glennjackman So what does that mean? Does it mean that running such a script through crontab doesn't allow a pop up message to show up in the gnome environment?
    – drN
    Apr 1 '12 at 19:38








1




1




I would put it in /opt/bin or ~/bin as a general best practice to not muck up where packages think things are.
– RobotHumans
Apr 1 '12 at 18:55






I would put it in /opt/bin or ~/bin as a general best practice to not muck up where packages think things are.
– RobotHumans
Apr 1 '12 at 18:55














If you run the script like so: /home/dnaneet/Desktop/./checkup.sh does it work? I would put /home/dnaneet/Desktop/checkup.sh
– LnxSlck
Apr 1 '12 at 18:59




If you run the script like so: /home/dnaneet/Desktop/./checkup.sh does it work? I would put /home/dnaneet/Desktop/checkup.sh
– LnxSlck
Apr 1 '12 at 18:59












@LnxSlck Yes, running /home/dnaneet/Desktop/./checkup.sh works fine. But /home/dnaneet/Desktop/checkup.sh may not work right? Because it needs a ./?
– drN
Apr 1 '12 at 19:03




@LnxSlck Yes, running /home/dnaneet/Desktop/./checkup.sh works fine. But /home/dnaneet/Desktop/checkup.sh may not work right? Because it needs a ./?
– drN
Apr 1 '12 at 19:03




1




1




I don't think cron knows anything about your X session.
– glenn jackman
Apr 1 '12 at 19:34




I don't think cron knows anything about your X session.
– glenn jackman
Apr 1 '12 at 19:34












@glennjackman So what does that mean? Does it mean that running such a script through crontab doesn't allow a pop up message to show up in the gnome environment?
– drN
Apr 1 '12 at 19:38




@glennjackman So what does that mean? Does it mean that running such a script through crontab doesn't allow a pop up message to show up in the gnome environment?
– drN
Apr 1 '12 at 19:38










2 Answers
2






active

oldest

votes


















64














One thing at a time:



First let's give you a user based bin folder:



cd ~/ && mkdir bin


You want to use crontab. Let's start with something really simple:



* * * * * touch /tmp/testing.txt


Okay, so that works



Now let's try running a script that does the same



* * * * * /home/username/bin/touchtest.sh


to run once a minute until you get it working

No you don't need a ./ in the middle of the line. ./ is for when you are giving relative urls.

Okay, so that works



Now let's try running a script that calls xmessage



* * * * * /home/username/bin/rebootwarn.sh


not working



First we need to not depend on environment variables. This includes path setting, x11 settings, or anything else(python and ruby environment variables come to mind...)



Let's make ours look a bit like anacron's proper cron file..I saved this as test



#Borrowed from anacron
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#End borrowed from anacron

* * * * * /bin/bash /home/username/bin/test.sh


Set to run once a minute



crontab test to import it



On to the script



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
up=$(uptime | grep "day" > /home/dnaneet/uptime.foo && awk < /home/dnaneet/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"`


Okay, so that works...what did we do?

We changed all the commands not to depend on paths we didn't explicitly set

We ran our script explicitly with bash

We told the script that we expect to be on DISPLAY :0.0






share|improve this answer























  • Thanks for the answer. You said "Let's make ours look a bit like anacron's proper cron file..I saved this as test".. OUR what? The crontab file? :-/
    – drN
    Apr 1 '12 at 20:23










  • Heres what I observed. First I had to get rid of the space before and after = for the line specifying DISPLAY. Second, when I edited my crontab file and added the PATH as suggested and set the time to run at a later time, the pop up window didn't show. However, the popup window showed fine when running the script using /bin/bash... what gives?
    – drN
    Apr 1 '12 at 20:34










  • What do you know, once I changed my script to export DISPLAY=:0.0, it worked fine. Although there was a significant lang of about 5 seconds after the clock chimed the hour when my pop up window should have showed... Any suggestions? But yes, your amends to the script work!
    – drN
    Apr 1 '12 at 20:49










  • No idea on the 5 second lag.
    – RobotHumans
    Apr 1 '12 at 20:51






  • 3




    I love the way you went through this step by step and then summarized it--thanks!
    – jbobbins
    Dec 29 '16 at 17:13



















8














The problem was solved read the manual in Google:



description:




  1. I have script using #!/bin/bash as header

  2. I put the script on /home/wc3/palert/


analysis:




  1. crontab can't run my script

  2. But if I run manually it show the output and also I can see the result on my web

  3. It means crontab can't get the environment not like when you run your script on your script folder


answer:





  1. put your environment using this line below on your script with:



    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/wc3/palert


    change this: /home/wc3/palert

    with: the place that you put your script e.g. /home/budi/script.sh




sample:



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/budi
# Script continues...


Try put your script on crontab.






share|improve this answer























  • doesn't work for me
    – John Joe
    Mar 21 '17 at 4:15










protected by Braiam Feb 7 '14 at 4:39



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?














2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









64














One thing at a time:



First let's give you a user based bin folder:



cd ~/ && mkdir bin


You want to use crontab. Let's start with something really simple:



* * * * * touch /tmp/testing.txt


Okay, so that works



Now let's try running a script that does the same



* * * * * /home/username/bin/touchtest.sh


to run once a minute until you get it working

No you don't need a ./ in the middle of the line. ./ is for when you are giving relative urls.

Okay, so that works



Now let's try running a script that calls xmessage



* * * * * /home/username/bin/rebootwarn.sh


not working



First we need to not depend on environment variables. This includes path setting, x11 settings, or anything else(python and ruby environment variables come to mind...)



Let's make ours look a bit like anacron's proper cron file..I saved this as test



#Borrowed from anacron
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#End borrowed from anacron

* * * * * /bin/bash /home/username/bin/test.sh


Set to run once a minute



crontab test to import it



On to the script



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
up=$(uptime | grep "day" > /home/dnaneet/uptime.foo && awk < /home/dnaneet/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"`


Okay, so that works...what did we do?

We changed all the commands not to depend on paths we didn't explicitly set

We ran our script explicitly with bash

We told the script that we expect to be on DISPLAY :0.0






share|improve this answer























  • Thanks for the answer. You said "Let's make ours look a bit like anacron's proper cron file..I saved this as test".. OUR what? The crontab file? :-/
    – drN
    Apr 1 '12 at 20:23










  • Heres what I observed. First I had to get rid of the space before and after = for the line specifying DISPLAY. Second, when I edited my crontab file and added the PATH as suggested and set the time to run at a later time, the pop up window didn't show. However, the popup window showed fine when running the script using /bin/bash... what gives?
    – drN
    Apr 1 '12 at 20:34










  • What do you know, once I changed my script to export DISPLAY=:0.0, it worked fine. Although there was a significant lang of about 5 seconds after the clock chimed the hour when my pop up window should have showed... Any suggestions? But yes, your amends to the script work!
    – drN
    Apr 1 '12 at 20:49










  • No idea on the 5 second lag.
    – RobotHumans
    Apr 1 '12 at 20:51






  • 3




    I love the way you went through this step by step and then summarized it--thanks!
    – jbobbins
    Dec 29 '16 at 17:13
















64














One thing at a time:



First let's give you a user based bin folder:



cd ~/ && mkdir bin


You want to use crontab. Let's start with something really simple:



* * * * * touch /tmp/testing.txt


Okay, so that works



Now let's try running a script that does the same



* * * * * /home/username/bin/touchtest.sh


to run once a minute until you get it working

No you don't need a ./ in the middle of the line. ./ is for when you are giving relative urls.

Okay, so that works



Now let's try running a script that calls xmessage



* * * * * /home/username/bin/rebootwarn.sh


not working



First we need to not depend on environment variables. This includes path setting, x11 settings, or anything else(python and ruby environment variables come to mind...)



Let's make ours look a bit like anacron's proper cron file..I saved this as test



#Borrowed from anacron
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#End borrowed from anacron

* * * * * /bin/bash /home/username/bin/test.sh


Set to run once a minute



crontab test to import it



On to the script



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
up=$(uptime | grep "day" > /home/dnaneet/uptime.foo && awk < /home/dnaneet/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"`


Okay, so that works...what did we do?

We changed all the commands not to depend on paths we didn't explicitly set

We ran our script explicitly with bash

We told the script that we expect to be on DISPLAY :0.0






share|improve this answer























  • Thanks for the answer. You said "Let's make ours look a bit like anacron's proper cron file..I saved this as test".. OUR what? The crontab file? :-/
    – drN
    Apr 1 '12 at 20:23










  • Heres what I observed. First I had to get rid of the space before and after = for the line specifying DISPLAY. Second, when I edited my crontab file and added the PATH as suggested and set the time to run at a later time, the pop up window didn't show. However, the popup window showed fine when running the script using /bin/bash... what gives?
    – drN
    Apr 1 '12 at 20:34










  • What do you know, once I changed my script to export DISPLAY=:0.0, it worked fine. Although there was a significant lang of about 5 seconds after the clock chimed the hour when my pop up window should have showed... Any suggestions? But yes, your amends to the script work!
    – drN
    Apr 1 '12 at 20:49










  • No idea on the 5 second lag.
    – RobotHumans
    Apr 1 '12 at 20:51






  • 3




    I love the way you went through this step by step and then summarized it--thanks!
    – jbobbins
    Dec 29 '16 at 17:13














64












64








64






One thing at a time:



First let's give you a user based bin folder:



cd ~/ && mkdir bin


You want to use crontab. Let's start with something really simple:



* * * * * touch /tmp/testing.txt


Okay, so that works



Now let's try running a script that does the same



* * * * * /home/username/bin/touchtest.sh


to run once a minute until you get it working

No you don't need a ./ in the middle of the line. ./ is for when you are giving relative urls.

Okay, so that works



Now let's try running a script that calls xmessage



* * * * * /home/username/bin/rebootwarn.sh


not working



First we need to not depend on environment variables. This includes path setting, x11 settings, or anything else(python and ruby environment variables come to mind...)



Let's make ours look a bit like anacron's proper cron file..I saved this as test



#Borrowed from anacron
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#End borrowed from anacron

* * * * * /bin/bash /home/username/bin/test.sh


Set to run once a minute



crontab test to import it



On to the script



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
up=$(uptime | grep "day" > /home/dnaneet/uptime.foo && awk < /home/dnaneet/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"`


Okay, so that works...what did we do?

We changed all the commands not to depend on paths we didn't explicitly set

We ran our script explicitly with bash

We told the script that we expect to be on DISPLAY :0.0






share|improve this answer














One thing at a time:



First let's give you a user based bin folder:



cd ~/ && mkdir bin


You want to use crontab. Let's start with something really simple:



* * * * * touch /tmp/testing.txt


Okay, so that works



Now let's try running a script that does the same



* * * * * /home/username/bin/touchtest.sh


to run once a minute until you get it working

No you don't need a ./ in the middle of the line. ./ is for when you are giving relative urls.

Okay, so that works



Now let's try running a script that calls xmessage



* * * * * /home/username/bin/rebootwarn.sh


not working



First we need to not depend on environment variables. This includes path setting, x11 settings, or anything else(python and ruby environment variables come to mind...)



Let's make ours look a bit like anacron's proper cron file..I saved this as test



#Borrowed from anacron
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#End borrowed from anacron

* * * * * /bin/bash /home/username/bin/test.sh


Set to run once a minute



crontab test to import it



On to the script



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
export DISPLAY=:0.0
up=$(uptime | grep "day" > /home/dnaneet/uptime.foo && awk < /home/dnaneet/uptime.foo '{ print $3 }')

[[ $up -gt 0 ]] && xmessage -center "Restart!"`


Okay, so that works...what did we do?

We changed all the commands not to depend on paths we didn't explicitly set

We ran our script explicitly with bash

We told the script that we expect to be on DISPLAY :0.0







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 7 '16 at 15:35









muru

1




1










answered Apr 1 '12 at 20:10









RobotHumans

22.8k362103




22.8k362103












  • Thanks for the answer. You said "Let's make ours look a bit like anacron's proper cron file..I saved this as test".. OUR what? The crontab file? :-/
    – drN
    Apr 1 '12 at 20:23










  • Heres what I observed. First I had to get rid of the space before and after = for the line specifying DISPLAY. Second, when I edited my crontab file and added the PATH as suggested and set the time to run at a later time, the pop up window didn't show. However, the popup window showed fine when running the script using /bin/bash... what gives?
    – drN
    Apr 1 '12 at 20:34










  • What do you know, once I changed my script to export DISPLAY=:0.0, it worked fine. Although there was a significant lang of about 5 seconds after the clock chimed the hour when my pop up window should have showed... Any suggestions? But yes, your amends to the script work!
    – drN
    Apr 1 '12 at 20:49










  • No idea on the 5 second lag.
    – RobotHumans
    Apr 1 '12 at 20:51






  • 3




    I love the way you went through this step by step and then summarized it--thanks!
    – jbobbins
    Dec 29 '16 at 17:13


















  • Thanks for the answer. You said "Let's make ours look a bit like anacron's proper cron file..I saved this as test".. OUR what? The crontab file? :-/
    – drN
    Apr 1 '12 at 20:23










  • Heres what I observed. First I had to get rid of the space before and after = for the line specifying DISPLAY. Second, when I edited my crontab file and added the PATH as suggested and set the time to run at a later time, the pop up window didn't show. However, the popup window showed fine when running the script using /bin/bash... what gives?
    – drN
    Apr 1 '12 at 20:34










  • What do you know, once I changed my script to export DISPLAY=:0.0, it worked fine. Although there was a significant lang of about 5 seconds after the clock chimed the hour when my pop up window should have showed... Any suggestions? But yes, your amends to the script work!
    – drN
    Apr 1 '12 at 20:49










  • No idea on the 5 second lag.
    – RobotHumans
    Apr 1 '12 at 20:51






  • 3




    I love the way you went through this step by step and then summarized it--thanks!
    – jbobbins
    Dec 29 '16 at 17:13
















Thanks for the answer. You said "Let's make ours look a bit like anacron's proper cron file..I saved this as test".. OUR what? The crontab file? :-/
– drN
Apr 1 '12 at 20:23




Thanks for the answer. You said "Let's make ours look a bit like anacron's proper cron file..I saved this as test".. OUR what? The crontab file? :-/
– drN
Apr 1 '12 at 20:23












Heres what I observed. First I had to get rid of the space before and after = for the line specifying DISPLAY. Second, when I edited my crontab file and added the PATH as suggested and set the time to run at a later time, the pop up window didn't show. However, the popup window showed fine when running the script using /bin/bash... what gives?
– drN
Apr 1 '12 at 20:34




Heres what I observed. First I had to get rid of the space before and after = for the line specifying DISPLAY. Second, when I edited my crontab file and added the PATH as suggested and set the time to run at a later time, the pop up window didn't show. However, the popup window showed fine when running the script using /bin/bash... what gives?
– drN
Apr 1 '12 at 20:34












What do you know, once I changed my script to export DISPLAY=:0.0, it worked fine. Although there was a significant lang of about 5 seconds after the clock chimed the hour when my pop up window should have showed... Any suggestions? But yes, your amends to the script work!
– drN
Apr 1 '12 at 20:49




What do you know, once I changed my script to export DISPLAY=:0.0, it worked fine. Although there was a significant lang of about 5 seconds after the clock chimed the hour when my pop up window should have showed... Any suggestions? But yes, your amends to the script work!
– drN
Apr 1 '12 at 20:49












No idea on the 5 second lag.
– RobotHumans
Apr 1 '12 at 20:51




No idea on the 5 second lag.
– RobotHumans
Apr 1 '12 at 20:51




3




3




I love the way you went through this step by step and then summarized it--thanks!
– jbobbins
Dec 29 '16 at 17:13




I love the way you went through this step by step and then summarized it--thanks!
– jbobbins
Dec 29 '16 at 17:13













8














The problem was solved read the manual in Google:



description:




  1. I have script using #!/bin/bash as header

  2. I put the script on /home/wc3/palert/


analysis:




  1. crontab can't run my script

  2. But if I run manually it show the output and also I can see the result on my web

  3. It means crontab can't get the environment not like when you run your script on your script folder


answer:





  1. put your environment using this line below on your script with:



    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/wc3/palert


    change this: /home/wc3/palert

    with: the place that you put your script e.g. /home/budi/script.sh




sample:



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/budi
# Script continues...


Try put your script on crontab.






share|improve this answer























  • doesn't work for me
    – John Joe
    Mar 21 '17 at 4:15
















8














The problem was solved read the manual in Google:



description:




  1. I have script using #!/bin/bash as header

  2. I put the script on /home/wc3/palert/


analysis:




  1. crontab can't run my script

  2. But if I run manually it show the output and also I can see the result on my web

  3. It means crontab can't get the environment not like when you run your script on your script folder


answer:





  1. put your environment using this line below on your script with:



    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/wc3/palert


    change this: /home/wc3/palert

    with: the place that you put your script e.g. /home/budi/script.sh




sample:



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/budi
# Script continues...


Try put your script on crontab.






share|improve this answer























  • doesn't work for me
    – John Joe
    Mar 21 '17 at 4:15














8












8








8






The problem was solved read the manual in Google:



description:




  1. I have script using #!/bin/bash as header

  2. I put the script on /home/wc3/palert/


analysis:




  1. crontab can't run my script

  2. But if I run manually it show the output and also I can see the result on my web

  3. It means crontab can't get the environment not like when you run your script on your script folder


answer:





  1. put your environment using this line below on your script with:



    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/wc3/palert


    change this: /home/wc3/palert

    with: the place that you put your script e.g. /home/budi/script.sh




sample:



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/budi
# Script continues...


Try put your script on crontab.






share|improve this answer














The problem was solved read the manual in Google:



description:




  1. I have script using #!/bin/bash as header

  2. I put the script on /home/wc3/palert/


analysis:




  1. crontab can't run my script

  2. But if I run manually it show the output and also I can see the result on my web

  3. It means crontab can't get the environment not like when you run your script on your script folder


answer:





  1. put your environment using this line below on your script with:



    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/wc3/palert


    change this: /home/wc3/palert

    with: the place that you put your script e.g. /home/budi/script.sh




sample:



#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/budi
# Script continues...


Try put your script on crontab.







share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 7 '16 at 15:36









muru

1




1










answered Apr 4 '13 at 15:03









budi satriyo

8111




8111












  • doesn't work for me
    – John Joe
    Mar 21 '17 at 4:15


















  • doesn't work for me
    – John Joe
    Mar 21 '17 at 4:15
















doesn't work for me
– John Joe
Mar 21 '17 at 4:15




doesn't work for me
– John Joe
Mar 21 '17 at 4:15





protected by Braiam Feb 7 '14 at 4:39



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?



Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕