• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

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

KlokWyze

Diamond Member
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
 
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 \
 
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.
 
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
 
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.
 
Back
Top