I am trying to run the script below in a crontab to keep my ip upto date.

#!/bin/bash

clear

echo "my ip form opendns: "
dig @208.67.222.220 myip.opendns.com +short `hostname`

echo "----------------------------- "
echo ""

myips=$(dig @208.67.222.220 myip.opendns.com +short `hostname`)

arryIP=(${myips// / })
echo "should have found my IP address now: ${arryIP[0]}"

echo " "
echo "updating home.houseofhawkins.com: "
echo "----------------------------------"
curl https://www.cloudflare.com/api_json.html \
  -d "a=rec_edit" \
  -d "tkn=mycode" \
  -d "id=myid" \
  -d "email=myemail" \
  -d "z=myzone" \
  -d "name=home" \
  -d "type=A" \
  -d "content=${arryIP[0]}" \
  -d "ttl=120"

echo "" echo "done updating home.houseofhawkins.com..."

if I do

. /home/me/updateIp.sh

This script will run successfully, but if I put this into a crontab it will always fail:

*/1 * * * * . /home/jon/updateIp.sh >> /home/jon/updateIpScript.log

the log file will have:

my ip form opendns:
86.180.163.89
67.215.65.132
-----------------------------

Not sure what is wrong

asked 03 Mar '13, 12:14

twiggy's gravatar image

twiggy
132
accept rate: 0%




First thing first, put a bash -x in front of the cron entry for the command, see exactly where it's failing. Also remove the dot in front.

so:

*/1 * * * * bash -x /home/jon/updateIp.sh >> /home/jon/updateIpScript.log

Post said output.

link

answered 03 Mar '13, 20:19

rfelsburg's gravatar image

rfelsburg ♦
6061618
accept rate: 25%

edited 03 Mar '13, 20:20

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×16
×7

Asked: 03 Mar '13, 12:14

Seen: 1,993 times

Last updated: 03 Mar '13, 20:20

powered by OSQA