How can I regularly upload a file from a folder onto my website every four hours?

To upload a file from a folder to your website automatically every four hours, you need two parts:

  1. A script that performs the upload
  2. A scheduler that runs it every 4 hours

Below are the most practical methods depending on your setup.


✅ Option 1 — Linux (Recommended for Raspberry Pi / Observatory PC)

Since you’ve worked with Linux for radio astronomy setups, this is likely the cleanest solution.

Step 1: Create an upload script

If your website supports FTP:

#!/bin/bash
HOST="ftp.yourwebsite.com"
USER="yourusername"
PASS="yourpassword"
LOCALFILE="/home/andrew/data/output.txt"
REMOTEFILE="public_html/output.txt"

ftp -inv $HOST <<EOF
user $USER $PASS
put $LOCALFILE $REMOTEFILE
bye
EOF

Save as:

upload.sh

Make it executable:

chmod +x upload.sh

Step 2: Schedule with cron (every 4 hours)

Edit crontab:

crontab -e

Add:

0 */4 * * * /home/andrew/upload.sh

This runs at:

  • 00:00
  • 04:00
  • 08:00
  • 12:00
  • 16:00
  • 20:00

✅ Better Method — Use SFTP (More Secure)

If your host supports SSH:

#!/bin/bash
sftp user@yourwebsite.com <<EOF
put /home/andrew/data/output.txt public_html/output.txt
bye
EOF

For automation without password prompts:


✅ Option 2 — Windows PC

Using Task Scheduler + WinSCP

  1. Install WinSCP
  2. Create a script file (upload.txt):
open sftp://user:password@yourwebsite.com
put C:\data\output.txt /public_html/output.txt
exit
  1. Create a batch file:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /script="C:\scripts\upload.txt"
  1. Use Windows Task Scheduler:
    • Trigger: Every 4 hours
    • Action: Run the batch file

✅ Option 3 — Using rsync (Best for Frequent Scientific Data)

If you’re uploading regularly updated radio data files:

rsync -avz /home/andrew/data/output.txt user@yourwebsite.com:public_html/

This only transfers changes and is ideal for observatory logs.

Schedule via cron exactly as above.


🔬 For Your Radio Observatory Use Case

If this is for:

  • Radio JOVE logs
  • SDR spectrum captures
  • Hydrogen line drift scans

You might want:

  • Automatic timestamped filenames
  • A rolling “latest” file
  • Automatic HTML page regeneration

By Admin

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.