1

Server: Ubuntu 20.04.2 LTS

Command: speedtest | speedtest-cli

I have a bash script to identity download & upload speed every 15 mins. When i execute it manually it works well but not on cron.

1st time, Suppose at 12:00 it executes properly and following is the output

Testing from AT&T Services (12.26.3.241)...

Retrieving speedtest.net server list...

Selecting best server based on ping...

Hosted by AWI networks (St. George, UT)

Testing download speed.........................................................................

Download: *** Mbit/s

Testing upload speed......................................................................

Upload: *** Mbit/s

2nd time, 12:15 :-

Retrieving speedtest.net configuration...

Testing from AT&T Services (12.26.3.241)...

Retrieving speedtest.net server list...

Selecting best server based on ping...

And when I check user's mail, Following is the error :-

ERROR: Unable to connect to servers to test latency.

1
  • any question? how to help with no view on the script and no view on the cron task ? – cmak.fr Mar 10 at 6:58
1

Same Problem here. It seams link the Server is overloaded at specific times. My cron-expression is "0 /15 * 1/1 * ? *" so the Job started: 10:00, 10:15, 10:30 ...

I changed the cron-expression to "0 4/15 * 1/1 * ? *" so the job starts: 10:04, 10:19, 10:34 ...

Solved the problem for me.

Kind Regards

1
  • Started facing the same problem. Queries at 00 minutes would fail. Changed to a different minute within the hour and it worked! – Daniel Mar 17 at 17:19
0

The classic reason for cron jobs not working when the same job works on the command line is that the environment is different. You can fix that with the following:

  1. Place the commands you want to run in a script not forgetting to add the shebang.
  2. Add a source command before the commands you want to run so that your .bashrc configuration is loaded.
  3. Make sure your script is executable.
  4. Adjust cron to run the script using the full path to the script.
    source /path/to/your/.bashrc

Good luck!

0

try adding following flags to your .sh script, it solved problem for me:

My script run_speedtest.sh:

#!/bin/bash
speedtest --accept-license --accept-gdpr >> /home/xxx/speedtesty/results

Crontab entry:

/10 * * * * /bin/bash /home/xxx/speedtesty/run_speedtest.sh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.