简体   繁体   中英

running a .sh file inside grails server

I am trying to run a bash file(.sh) to make some photos conversion in my grails server, my code is the following to make that task:

        def folderTo = grailsAttributes.getApplicationContext().getResource("/files/").getFile()
        def f = new File(folderFrom.toString())
        def cmd = '/bin/bash /var/lib/tomcat6/webapps/malibueventapp-qa/uploads/convertPhoto.sh /var/lib/tomcat6/webapps/malibueventapp-qa/uploads /var/lib/tomcat6/webapps/malibueventapp-qa/files'
        def process = runtime.exec(cmd, null, f);

the problem here is, when I am running it in the server, I am getting the follow error:

Cannot run program "/bin/bash" (in directory "/var/lib/tomcat6/webapps/malibueventapp-qa/uploads"): java.io.IOException: error=12, Cannot allocate memory

that is the only message error i am getting! so I have no ideas what to do!

some sugestions?!

thanks

Sounds like you're not alone:

How to solve "java.io.IOException: error=12, Cannot allocate memory" calling Runtime#exec()?

Above SO thread provides a (possible) solution to your problem, give it a shot.

just to sum-up what I did!

I increased the swap memory: http://www.linux.com/learn/tutorials/442430-increase-your-available-swap-space-with-a-swap-file

and also runned:

echo 1 > /proc/sys/vm/overcommit_memory

cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM