1) When I run a script name myscript.sh, I do not see any error nor does the script get executed. What can be the possible reason? This was an interview question asked recently
eg.
sh myscript.sh
2) I manually check if my directory is being updated every 5 mins. How can I automate this shell scripting?
Question:
------------
When I run a script name myscript.sh, I do not see any error nor does the script get executed. What can be the possible reason?
Answer:
------------
First whether the script have executable permission(+x) permission. If the script did not have executable permission it will not run as a local user
If you are running the script as root user executable permission is not required.
If you run a script and no errors available means, First open the shell script and see what content is available inside it.
Question
-----------------
I manually check if my directory is being updated every 5 mins. How can I automate this shell scripting?
Answer:
-----------
One word "crontab".
Go to google and search for crontab with examples in linux lot of articles are available.
This script has something in it but I have named it useless.sh...
#/bin/bash --posix
NOP()
{
:
}
NOP
exit 1
Results...
Last login: Mon Nov 11 20:00:59 on ttys000
AMIGA:barrywalker~> chmod 755 useless.sh
AMIGA:barrywalker~> ./useless.sh
AMIGA:barrywalker~> echo "$?"
1
AMIGA:barrywalker~> _
As you can see it works perfectly the way you described and my exit _code_ was correct.
There were no error reports, nothing appeared on screen and and my prompt returned as normal.
Maybe your script IS running but without seeing any of your attempts we can never know...