Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Help understand cron script

    Scheduled Pinned Locked Moved pfSense Packages
    5 Posts 2 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      archedraft
      last edited by

      I found this guide that another pfsense user setup to work with private internet access to determine what ports are open. He posted this guide in June 2013:

      So I did manage to get this working. Turns out I was simply missing an @ symbol. Here are the 3 scripts. I will type up a tutorial later this week (busy, just got a few RE4 WD drives, tinkering with RAID).

      Script Contents: (all in ETC folder)

      Script1:
      #!/bin/sh
      /sbin/ifconfig ovpnc1 | /usr/bin/grep -w "inet" | /usr/bin/cut -f2 -d " " > /tmp/vpn_ip

      Script2:
      #!/bin/sh
      /usr/local/bin/curl ifconfig.me/ip|tee /tmp/vpn_external

      Script3:
      #!/bin/sh
      /usr/local/bin/curl -d "user=USERNAME&pass=PASSWORD&client_id=$@(/bin/cat ~/.pia_config)&local_ip=$(/bin/cat /tmp/vpn_ip)" https://www.privateinternetaccess.com/vpninfo/port_forward_assignment -o /tmp/vpnportforward

      NOTE: I renamed the pia client config to "pia_config" so you may need to change that. and of course, enter your username and password.

      CRON:

      *  *  *  *  root  /usr/bin/nice -n20 /etc/script3.sh
      */60

      *  *  *  *  root  /usr/bin/nice -n20 /etc/script1.sh
      */25
      *  *  *  *  root  /usr/bin/nice -n20 /etc/script2.sh
      */26

      I installed the Cron package and set it up (please see attached image). My question is where does this script output the file and did I setup my cron settings correctly?
      Capture1.PNG
      Capture1.PNG_thumb

      1 Reply Last reply Reply Quote 0
      • B
        bryan.paradis
        last edited by

        Could you post the guide you were working off of?

        1 Reply Last reply Reply Quote 0
        • A
          archedraft
          last edited by

          Sure second post 4th page

          https://www.privateinternetaccess.com/forum/index.php?p=/discussion/180/port-forwarding-without-the-application-advanced-users/p4

          1 Reply Last reply Reply Quote 0
          • A
            archedraft
            last edited by

            I have tried to type in the scripts manually into the command lines.

            The first script works and output the /tmp/vpn_ip file
            the second scripts errors and states "/usr/local/bin/curl: Command not found.

            Any thought?

            EDIT:
            Ok sencond script works after I typed: pkg_add -r curl

            1 Reply Last reply Reply Quote 0
            • A
              archedraft
              last edited by

              The third script now errors and says "Illegal variable name."

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.