bash - Crontab hanging on pipeline, scope, or poor syntax -
i have shell script works fine user , works halfway in crontab. finishes rm line, however, , hangs on awk line:
#!/bin/bash get_listeners.pl > temp.txt #accesses icecast admin page , puts useful metrics in temp.txt date +\%s > unpaired.txt grep "current listeners" temp.txt | sed 's/[^0-9]//g' >> unpaired.txt #first line of unpaired.txt time, second line number of listeners sed '$!n;s/\n/ /' unpaired.txt >> data.dat #combine 2 lines , append data file rm unpaired.txt #tidy a=$(($(date +\%s) - 86400)) | awk -v a=$1 '{if ($1 >= a) print $1,$2}' data.dat > data2.dat #get variable of 24 hours ago; copy lines last 24 hours new file gnuplot < demo.plt #make plot data in new file
all paths explicit in crontab; i've removed them here keep concise.
all files set 777 , data.dat builds steadily (job runs once per minute) never migrates data on second file in awk line. if can point out looks wrong awk line, i'm near positive that's it's messing up. can variables not pipelined in cron? thank you.
#get variable of 24 hours ago; copy lines last 24 hours new file
judging comment, want this:
a=$(($(date +\%s) - 86400)) awk -v a="$a" '$1 >= a{print $1,$2}' data.dat > data2.dat
Comments
Post a Comment