Scripts can't append to text files with crontab??????

KlokWyze

Diamond Member
Sep 7, 2006
4,451
9
81
www.dogsonacid.com
I cannot for the life of me figure out why this isn't working. All versions of this script work fine when I run it manually, BUT when it is executed via crontab or cron.hourly it cannot append to a file. The "endlines" append, but the text does not.

Permissions are 777 on everything. I've tried using both root and my own username.... anyone have any ideas?

Using CentOS 6.2

Code:
[root@localhost ccticker]# cat ccticker.sh
#!/bin/bash

/usr/bin/curl https://btc-e.com/api/2/ltc_usd/ticker >> ltc.txt
echo \ >> /home/root/ccticker/ltc.txt

Code:
[root@localhost ccticker]# cat ccticker2.sh
#!/bin/bash

wget https://btc-e.com/api/2/ltc_usd/ticker
cat /home/root/ccticker/ticker >> /home/root/ccticker/ltc.txt
echo \ >> /home/root/ccticker/ltc.txt
rm -f /home/root/ccticker/ticker

Code:
[root@localhost ccticker]# ll
total 16
-rwxrwxrwx. 1 root root 192 Jul 21 14:26 ccticker2.sh
-rwxrwxrwx. 1 root root 131 Jul 21 14:46 ccticker.sh
-rwxr-xr-x. 1 root root 114 Jul 14 23:26 ccticker.sh.backup
-rwxrwxrwx. 1 root root  26 Jul 21 14:52 ltc.txt

Code:
[root@localhost ccticker]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
*/2 * * * * root ./home/root/ccticker/ccticker.sh
*/2 * * * * root ./home/root/ccticker/ccticker2.sh
 

Jodell88

Diamond Member
Jan 29, 2007
8,762
30
91
I'm a bash noob, so please bear with me if I'm asking a simple question.

What is this command expected to return?
Code:
echo \
 

KlokWyze

Diamond Member
Sep 7, 2006
4,451
9
81
www.dogsonacid.com
I'm a bash noob, so please bear with me if I'm asking a simple question.

What is this command expected to return?
Code:
echo \

That's printing an "endline" to the the screen. I want to append the text to the file and insert an "enter" or endline to just parse out the info a little.
 

KlokWyze

Diamond Member
Sep 7, 2006
4,451
9
81
www.dogsonacid.com
OK so the following script worked. It's like cat doesn't work and you HAVE to use echo..........????

Code:
[root@localhost ccticker]# cat ccticker3.sh
#!/bin/bash

GRUMPS=$(curl https://btc-e.com/api/2/ltc_usd/ticker)
echo $GRUMPS >> /home/root/ccticker/ltc.txt
 

Scarpozzi

Lifer
Jun 13, 2000
26,391
1,780
126
OK so the following script worked. It's like cat doesn't work and you HAVE to use echo..........????

Code:
[root@localhost ccticker]# cat ccticker3.sh
#!/bin/bash

GRUMPS=$(curl https://btc-e.com/api/2/ltc_usd/ticker)
echo $GRUMPS >> /home/root/ccticker/ltc.txt
Yeah...makes sense....my understanding is that cat prints to the screen, not the pipe.