Debuggging bash cron scripts.

2014-09-01 154 words 1 min read

I have to several times debug scripts that I get complain about working when logging in normally but they do not work when run in cron mode. So, quite a lot of times, redirecting the stderr of the script is all that is required to see what is happening, but sometimes that just does not help if the script is calling another script which is mis-behaving and under lot of other conditions. So, how to at-least take a look at why these are failing, login with ssh.

Use the “noprofile” option to ensure that user profile settings are not sourced and you should be good to test. (Do not try to do this with “user#localhost”, as by that time you would have already sourced the profile.)

ssh -t user@server "bash --noprofile"

Now, if you want to run bash like this, then you need a terminal, and thus dont forget the “-t” option as well.


Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it