2015-04-14 37 views
0

我有一個罕見的問題。錯誤在crontab中,而不是在控制檯中

當我執行通過控制檯文件,它工作得很好,但是當我用crontab中執行它(同一個文件),我在代碼

join -j 1 -t ',' <(sort $dir/Xem3.csv) <(sort $dir/coordenades.csv)|awk -F "," '{print $15","$16","$17"," $3"," $4","$18"," $5"," $6","$7","$8"," $9","$10","$11","$12","$13}' > $dir/Xem4.csv 

在錯誤的以下部分收到錯誤crontab的日誌是

/home/enric/proves/web.sh: line 95: syntax error near unexpected token `(' 
/home/enric/proves/web.sh: line 95: `join -j 1 -t ',' <(sort $dir/Xem3.csv) <(sort $dir/coordenades.csv)|awk -F "," '{print $15","$16","$17"," $3"," $4","$18"," $5"," $6","$7","$8"," $9","$10","$11","$12","$13}' > $dir/Xem4.csv' 

有什麼想法嗎?

我的劇本是

#/bin/bash 

dir=/home/enric/proves 

join -j 1 -t ',' <(sort $dir/Xem3.csv) <(sort $dir/coordenades.csv)|awk -F "," '{print $15","$16","$17"," $3"," $4","$18"," $5"," $6","$7","$8"," $9","$10","$11","$12","$13}' > $dir/Xem4.csv 

tr -d '\r' < $dir/Xem4.csv > $dir/out.csv 
+2

您的控制檯腳本是否指定了它正在使用的shell?例如。你確定你的crontab與你的交互式登錄使用相同的shell嗎? – AlG

+1

看起來您正在使用流程替換'<(sort ...)',這是一個bash功能,但您的腳本或者是以'sh script.sh'或'。/ script.sh'作爲錯誤的shebang調用。它應該是頂部的'#!/ bin/bash'。 –

+0

頂部我有#/ bin/bash –

回答

2

你的第一線是不是一個家當線。你想要#!/usr/bin/env bash。如果沒有感嘆號,則該行只是另一個註釋,腳本將在cron使用的shell中執行(通常爲/bin/sh)。 <(my_command) is a bashism,因此語法錯誤。

相關問題