# Execution Limitation to non interactive ssh session

## IgnitusBoyone

Ok, is there any obvious reason like security permissions why the following script would fail when executed over ssh with a supplied command

File updatecron.sh

```
#!/bin/bash

crontab -l > crontab.bak

cp crontab.bak crontab

echo " 30 2 * * * /usr/local/bin/targetprogram 2>&1" >> crontab

crontab crontab
```

This simple would be called using 

```
ssh user@host updatecron.sh
```

The file was put in place prior to the attempt to run it remotly. Essentially I had over 100 servers I needed to hit with a crontab update, using a usr who doesn't have admin access.  Now the script worked in an interactive ssh session just fine, but when ran as stated above in a non interactive mode it produced an empty cron file.  I would understand no change, but instead it saved the previous cron to crontab.added the 3rd line to crontab and then saved an empty crontab to the users cron job erasing all previous cron jobs.  I was thinking this has something to do with enviroment or not having the ability to run sbin apps, but I couldn't find anything on the internet.

If you have any feedback I would greatly appriciate it and if you have a better idea on how to automate commands like this when pushing to multiple servers I'm all ears.Last edited by IgnitusBoyone on Wed Jun 08, 2011 2:47 pm; edited 1 time in total

----------

## feystorm

crontab -l > crontab.bak

cp crontab.back crontab

 :Wink: 

----------

## IgnitusBoyone

Nice catch on the typo. I'm going to correct it in the post above. I was typing the script from memory which doesn't contain the same error, any other ideas?

----------

## feystorm

I doubt any of those commands care about having a terminal available. However you can try ssh with '-tt' which will force creation of a tty on the remote end.

----------

## tomk

Moved from Documentation, Tips & Tricks to Networking & Security as it's a support request.

----------

