One of my script is making new .sh files in /tmp/ folder how can I setup that all new files in /tmp/ folder will get chmod -x automaticaly because my script is failing when trying to run scripts in /tmp/


Wrong approach. While creating the script, set the x flag as well! Or, when executing the created script, prepend sh or bash to it:

Instead of:



bash /tmp/myscript.sh

Like that you don't have to make the script executable.

| improve this answer | |
  • What if I can't edit that file? it's very complicated script involving both .sh and .php – John Nov 7 '14 at 11:16
  • Than make a cron job to run: chmod +x -R /tmp/*.sh – Frantique Nov 7 '14 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.