You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all,
if I run this script, it runs properly
/usr/local/bin/csvsql --query "select * from archiviotemp_05 group by numero_protocollo" /var/www/test/archiviotemp_05.csv > /var/www/test/06_archivio.csv
If I run it via cron I have a 0 kb file. This my cron job:
*/5 * * * * root /bin/bash /usr/local/bin/csvsql --query "select * from archiviotemp_05 group by numero_protocollo" /var/www/test/archiviotemp_05.csv > /var/www/test/06_archivio.csv > /dev/null 2>&1
It seems to me that there is some problem related to csvsql and cron, because I use cron without any problems with the other csvkit commands. But it could be stupid error of mine.
The same without /bin/bash (I think it's not necessary):
*/5 * * * * root /usr/local/bin/csvsql --query "select * from archiviotemp_05 group by numero_protocollo" /var/www/test/archiviotemp_05.csv > /var/www/test/06_archivio.csv > /dev/null 2>&1
Hi I know that this is probably not an issue, but I need to know if anyone is able to run some csvsql command via cron job. If yes, I will know it's an error of mine and I will work on it.
Hi Andrea, it's def possible to use the csvkit commands with cron. Looking at your command my best guess would be it's something to do with the second redirect on your command: > /dev/null 2>&1. Or it could be that universal devil: permissions. Either way, I'm 90% sure this isn't a csvkit issue.
Hi @onyxfish ,
I'm a beginner, so I may be wrong.
In my test csvsql does not work using cron.
It works only if write the command in this way:
csvsql --query "select * from archiviotemp group by numero_protocollo" --tables archiviotemp < $folder/archiviotemp.csv > $folder/archivio.csv
This solution has been provided to me by my friend. Moreover he looked at your code and he told me to tell you:
"I see you add stdin as input file if it's not a tty, but there is no tty when the script runs as a cron job, and it tries to read from stdin. On line 58-63 you should consider this variant."
@aborruso Here is my crone command
29 * * * * python /mnt/scripts/marketplace007/files/checkImsVimSync.py >> /mnt/scripts/marketplace007/files/error.log 2>&1
here is command in checkImsVimSync python file
path="/mnt/scripts/marketplace007/files"
os.system('csvsql --query "select * from test" --tables test<'+path+'/test.csv > '+path+'/nonsynced.csv')
Activity
aborruso commentedon Oct 5, 2014
The same without /bin/bash (I think it's not necessary):
*/5 * * * * root /usr/local/bin/csvsql --query "select * from archiviotemp_05 group by numero_protocollo" /var/www/test/archiviotemp_05.csv > /var/www/test/06_archivio.csv > /dev/null 2>&1
Thank you
aborruso commentedon Oct 29, 2014
Hi I know that this is probably not an issue, but I need to know if anyone is able to run some csvsql command via cron job. If yes, I will know it's an error of mine and I will work on it.
Thank you very much
onyxfish commentedon Nov 22, 2014
Hi Andrea, it's def possible to use the csvkit commands with cron. Looking at your command my best guess would be it's something to do with the second redirect on your command:
> /dev/null 2>&1. Or it could be that universal devil: permissions. Either way, I'm 90% sure this isn't a csvkit issue.aborruso commentedon Nov 22, 2014
Hi @onyxfish ,
I'm a beginner, so I may be wrong.
In my test csvsql does not work using cron.
It works only if write the command in this way:
csvsql --query "select * from archiviotemp group by numero_protocollo" --tables archiviotemp < $folder/archiviotemp.csv > $folder/archivio.csv
This solution has been provided to me by my friend. Moreover he looked at your code and he told me to tell you:
"I see you add stdin as input file if it's not a tty, but there is no tty when the script runs as a cron job, and it tries to read from stdin. On line 58-63 you should consider this variant."
I hope to be helpful.
Thank you
dazl commentedon Dec 20, 2014
thank you @aborruso, in my bash script I had to change
to
for it to work within a rundeck task
jommgoncalves commentedon Jun 20, 2016
Hi,
I have the same problem. The proposed workaround it works for one table but for multiple tables it doesn't work :\
Anyone knows how can I solve this problem?
Thank you very much,
jpmckinney commentedon Jun 21, 2016
@jommgoncalves You can pass multiple table names with
--tables.jommgoncalves commentedon Jun 21, 2016
@jpmckinney Thank you for your quickly reply. It works with your suggestion!
imwikaash commentedon Mar 21, 2017
Hi all,
I am using csvsql in a script . it is executing fine. But the same is not working using a crob job.
Please help.
aborruso commentedon Mar 21, 2017
@imwikaash please paste here your crone command
imwikaash commentedon Mar 21, 2017
@aborruso Here is my crone command
29 * * * * python /mnt/scripts/marketplace007/files/checkImsVimSync.py >> /mnt/scripts/marketplace007/files/error.log 2>&1
here is command in checkImsVimSync python file
path="/mnt/scripts/marketplace007/files"
os.system('csvsql --query "select * from test" --tables test<'+path+'/test.csv > '+path+'/nonsynced.csv')
aborruso commentedon Mar 21, 2017
@imwikaash try to put the absolute path of
csvsqlinside your py fileimwikaash commentedon Mar 21, 2017
Thanks @aborruso
working fine after adding the absolute path of csvsql ..
Add crontab use case
Add crontab use case