baker
June 2, 2020, 3:50pm
1
The code which is working fine independently is not working with nohup
Program is to check for any new file generation on particular folder
if [[ $name == * ]]; then
echo "core file generated in the $path with core file name $name"
fi
Getting the error " [[ksadsasassdds: command not found"
ps: "ksadsasassdds" this is the value of name
Please, double quote the "$name"
variable.
What are you comparing it with, what is *
meaning in if
condition ?
Regards
Peasant.
baker
June 3, 2020, 3:13am
3
Thanks for the reply , i just to check if the file is generated or not
#Waiting in a loop for core file generation on the directory user specified
inotifywait -q -e create -m $DIR | while read path events name;
do
if [[ $name == * ]]; then
echo "core file generated in the $path with core file name $name"
#calling pythin script for sending notification to user
python mail.py $path $name $EMAIL
fi
Check out incrond
for inotify usage.
Please use code tags for your future queries!
Dear members, moderators and others.
While working on <insert project>, a need has surfaced to watch a directory, and when a file comes, to do appropriate action.
So, i started writing some shell code, aware of linux inotify-tools package with inotifywait .
Also, i'm seeing a lot of similar request on these forums for such kind of actions.
Since linux kernel inotify subsystem is used extensively in the wild (for instance ClamAV), was sure that there was a cleaner way, not resorting to hi…
Here is a simple example incorporating your code for check, please declare MAIL variable, as i did not.
#!/bin/bash
python mail.py $1 $2 $MAIL
And incron installed with entry as follows :
/directory/to/watch IN_CLOSE_WRITE,IN_MOVED_TO /path/to/script/script.sh $@ $#
Hope that helps
Regards
Peasant.
2 Likes
system
Closed
August 2, 2020, 3:35am
5
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.