Why my git command has no output in crontab but works well run this script manually?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why my git command has no output in crontab but works well run this script manually?
# 1  
Old 11-03-2013
Why my git command has no output in crontab but works well run this script manually?

cat /home/lyang001/update.sh
Code:
#!/bin/sh
#shopt -s expand_aliases
HOME_DIR=/home/lyang001/updates
UPDATE_MAIL=${HOME_DIR}/updates.mail
rm $UPDATE_MAIL -rf
cd $HOME_DIR/wr-kernel
git log --no-merges --since="20 day ago" --name-status --pretty=format:"%an %h %s %cd"  origin/WRLINUX_5_0_1_HEAD >> $UPDATE_MAIL
echo "  a               " >> $UPDATE_MAIL
sync
sleep 10

I manually run above scripts it works well and I can get the git' output in update.mail

but I use crontab
Code:
40 11 * * * /home/lyang001/update.sh

it can't get the git's output
# 2  
Old 11-03-2013
Why my git command has no output in crontab but works well run this script manually?

Code:
#!/bin/sh
#shopt -s expand_aliases
HOME_DIR=/home/lyang001/updates
UPDATE_MAIL=${HOME_DIR}/updates.mail
rm $UPDATE_MAIL -rf
cd $HOME_DIR/wr-kernel
git log --no-merges --since="20 day ago" --name-status --pretty=format:"%an %h %s %cd"  origin/WRLINUX_5_0_1_HEAD >> $UPDATE_MAIL
echo "  a               " >> $UPDATE_MAIL
sync
sleep 10

I manually run above scripts it works well and I can get the git' output in update.mail

but I use crontab
Code:
40 11 * * * /home/lyang001/update.sh

it can't get the git's output

---------- Post updated at 08:46 PM ---------- Previous update was at 08:42 PM ----------

please delete this one, I just make a mistake

Lei
# 3  
Old 11-04-2013
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace string works on command-line but fails when run from shell script

I wish to replace "\\n" with a single white space. The below does the job on command-line: $ echo '/fin/app/scripts\\n/fin/app/01/sql' | sed -e 's#\\\\n# #g'; /fin/app/scripts /fin/app/01/sql However, when i have the same code to a shell script it is not able to get me the same output:... (8 Replies)
Discussion started by: mohtashims
8 Replies

2. Shell Programming and Scripting

Calling bash script works when called manually but not via Cron?

Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin. Basically the path structure is ... (6 Replies)
Discussion started by: wyclef
6 Replies

3. UNIX for Dummies Questions & Answers

Script runs manually but not from crontab in UNIX

Hi Guys, I am executing the script called Delet.sh manually it is successfully completing the task but it is failing to run vi cron tab, I tried to pass PATH & .profile before execution but no luck, Any suggestions? Script below #!/usr/bin/ksh #set -x # Purpose : Delete folders file from... (9 Replies)
Discussion started by: Anilsa77
9 Replies

4. Shell Programming and Scripting

How to give full access to output files created by .sh script run via crontab?

Hi Expert, I have a .sh script in my home/new_dir/script.sh This script creates number of output files at home/new_dir/email, home/new_dir/logs dir. I am running this script using crontab (owner root). Now this output files are getting created with rw-r----- 1 root root So if i... (2 Replies)
Discussion started by: Jeet1982
2 Replies

5. Shell Programming and Scripting

Output differs when run manually and when cron job executes it

I get a different output when i manually run the .sh script and when it is run by a cron job. Please help me .. TMP1="/lhome/bbuser/script/wslog/sar.t1" TMP2="/lhome/bbuser/script/wslog/sar.t2" TMP3="/lhome/bbuser/script/wslog/sar.t3" OUTPUT="/lhome/bbuser/script/wslog/sar.out"... (8 Replies)
Discussion started by: nithinankam
8 Replies

6. Solaris

prtdiag command works only from commandline manually

When i run the command sudo /usr/sbin/prtdiag manually on a solaris 10 box, it works as expected. But the same command from my java code gives me the following error. picl_initialize failed: Daemon not responding. I am unable to figure out why is not running from my code.:wall: (3 Replies)
Discussion started by: randeepsp
3 Replies

7. Shell Programming and Scripting

Script working when run manually but not in crontab showing path not found

i have a script running using variable defined in .profile when i run that script manually its working but when i run the same script through cron its giving path not found I had defined path in .profile (3 Replies)
Discussion started by: raj_saini20
3 Replies

8. Shell Programming and Scripting

Script runs fine manually but not in crontab

Hello Guys, I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following. 1) When I manually execute following script it runs successfully with below output. bash-3.00# more smssend #!/bin/bash echo -e "<Request... (16 Replies)
Discussion started by: umarsatti
16 Replies

9. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hello all, I'm new here and have a question if you don't mind helping me. I have a script that will work if I kick if off manually but not from Cron. My cron entry is this: 05,20,35,50 * * * * /scripts/status.sh > /dev/null 2>&1 The first script (works fine) is this: #!/bin/sh # #... (14 Replies)
Discussion started by: hs3082
14 Replies

10. Shell Programming and Scripting

Script runs manually but not correctly from crontab

Hi all I have this inside a shell script (bash): cd DIRECTORY find . -maxdepth 1 | sed 's#./##' | /usr/bin/xargs -I '{}' chown -Rv '{}' /DIRECTORY/'{}' All the directories in this location are named after usernames, so it simply sets the owner to that of the username of the folder. It... (5 Replies)
Discussion started by: fakesy
5 Replies
Login or Register to Ask a Question