ar- / incron

cron-like daemon which handles filesystem events
Other
229 stars 51 forks source link

Having issues writing script output to file #49

Open adam3039 opened 6 years ago

adam3039 commented 6 years ago

I've got an incrontab rule set up to react to a file being added to a particular directory on my ubuntu box, and run a script. This works fine, but my goal is to print the output of that script to a file.

I've tried a few different ways to go about it, and the only way I've been able to get it working so far is to take the generated command that incrontab creates, and run it myself. So my thinking is that its possible, I'm likely just missing something obvious to an experience linux user.

I've shortened some of the commands for brevity's sake. "watchdir" "scriptPath" and "arg1" are all paths. I am bringing in two arguments to the script, arg1, and the filename wildcard from the cron job.

I've tried: (These run the script, but don't output to file)

watchdir IN_CREATE scriptPath arg1 $# >> /home/ubuntu/logs/log-$# 2>&1

watchdir IN_CREATE scriptPath arg1 $# &>> /home/ubuntu/logs/log-$#

(These do nothing at all)

watchdir IN_CREATE /bin/bash scriptPath arg1 $# >> /home/ubuntu/log/log-$# 2>&1

watchdir IN_CREATE /bin/bash scriptPath arg1 $# &>> /home/ubuntu/log/log-$#

If I run 'tail /var/log/syslog' and grab the command generated from the incrontab below and paste it into the shell, it works fine

watchdir IN_CREATE scriptPath arg1 $# &>> /home/ubuntu/logs/log-$#

This works

scriptPath arg1 mission-LHPUQ7ezcF0s0UwVgUR.txt &>> /home/ubuntu/logs/log-mission-LHPUQ7ezcF0s0UwVgUR.txt

Any insight as to what I could be missing?