LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   incrontab cron how to combine commands (https://www.linuxquestions.org/questions/linux-software-2/incrontab-cron-how-to-combine-commands-701076/)

afonit 01-30-2009 01:30 PM

incrontab cron how to combine commands
 
if anyone is familiar with incrontab


I am wondering how to combine commands, for instance:

this is my currently running command:
/home/afonit/Desktop/theone IN_ATTRIB convert -density 150 -format JPEG $@/$# $@/$#.JPEG

which is just saying for each file dropped into this cirectory convert it to a jpeg at 150 dpi.



but the problem is I then want it to run this command:

rm -fr /home/afonit/IMD/in/*


though I do not see a way to combine them. I know in the terminal I can just do a simple "&&" between them and it works great, but I don't see a way to do this in incrontab.

BrianK 01-30-2009 01:36 PM

Not sure exactly what incrontab is, but it sounds like you could just make a script that does the two things & run that script from cron, i.e.:

Code:

#!/bin/tcsh -f

/home/afonit/Desktop/theone IN_ATTRIB convert -density 150 -format JPEG $@/$# $@/$#.JPEG && rm -fr /home/afonit/IMD/in/*

then run that script from a cron job.

afonit 01-30-2009 01:59 PM

thanks, I will look into how to write scripts and execute them (never done that before) but it should be a good learning experience.


to answer your query of incrontab, it is like cron, but instead of being base on time, it is based on file system events - and uses inotify to do it.

So, if you want an action done when someone saves a file to a directory etc... icrontab is your guy.

afonit 01-30-2009 02:11 PM

dang, that did it - and quick too.

thanks for your help, I really appreciate it, I will look and learn more about this scripting, again, I appreciate your time.


All times are GMT -5. The time now is 09:52 AM.