Skip to main content
added 325 characters in body
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

You don't tell us how this fails, but I am guessing you don't see it executed.

First of all, your script will never work since while($true) isn't valid shell syntax. I assume you want something like this:

true=1
while(($true)); do ... ; done

The more common idiom for that is:

while : ; do ... ; done

Or (true is a command):

while true; do ... ; done

This is most likely because you are using relative paths in your script:

./transfermysql.sh > file.txt

Replace that with the full path:

/path/to/transfermysql.sh > /path/to/file.txt

Next, I also suspect that bcp is not in cron's PATH, so use the full path to that as well:

/path/to/bcp tablename in file.txt -S ***********.com,**** -U **** -P *********** -d ********* -c

Finally, I don't know why you would want :> file.txt since your first command overwrites its contents anyway, but if you do need it for some reason, you need to use the full path there too: > /path/to/file.txt.

You don't tell us how this fails, but I am guessing you don't see it executed. This is most likely because you are using relative paths in your script:

./transfermysql.sh > file.txt

Replace that with the full path:

/path/to/transfermysql.sh > /path/to/file.txt

Next, I also suspect that bcp is not in cron's PATH, so use the full path to that as well:

/path/to/bcp tablename in file.txt -S ***********.com,**** -U **** -P *********** -d ********* -c

Finally, I don't know why you would want :> file.txt since your first command overwrites its contents anyway, but if you do need it for some reason, you need to use the full path there too: > /path/to/file.txt.

You don't tell us how this fails, but I am guessing you don't see it executed.

First of all, your script will never work since while($true) isn't valid shell syntax. I assume you want something like this:

true=1
while(($true)); do ... ; done

The more common idiom for that is:

while : ; do ... ; done

Or (true is a command):

while true; do ... ; done

This is most likely because you are using relative paths in your script:

./transfermysql.sh > file.txt

Replace that with the full path:

/path/to/transfermysql.sh > /path/to/file.txt

Next, I also suspect that bcp is not in cron's PATH, so use the full path to that as well:

/path/to/bcp tablename in file.txt -S ***********.com,**** -U **** -P *********** -d ********* -c

Finally, I don't know why you would want :> file.txt since your first command overwrites its contents anyway, but if you do need it for some reason, you need to use the full path there too: > /path/to/file.txt.

Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

You don't tell us how this fails, but I am guessing you don't see it executed. This is most likely because you are using relative paths in your script:

./transfermysql.sh > file.txt

Replace that with the full path:

/path/to/transfermysql.sh > /path/to/file.txt

Next, I also suspect that bcp is not in cron's PATH, so use the full path to that as well:

/path/to/bcp tablename in file.txt -S ***********.com,**** -U **** -P *********** -d ********* -c

Finally, I don't know why you would want :> file.txt since your first command overwrites its contents anyway, but if you do need it for some reason, you need to use the full path there too: > /path/to/file.txt.