Home > Mobile >  cron job failed to run
cron job failed to run

Time:11-27

Retrieval of graphics card sales information

#!/bin/bash
curl=$(which curl)
RTX3060="http://0.0.0.0:5000/rtx3060"
RTX3070="http://0.0.0.0:5000/rtx3070"
RTX3080="http://0.0.0.0:5000/rtx3080"
RTX3090="http://0.0.0.0:5000/rtx3090"
RX6700="http://0.0.0.0:5000/rx6700"
function output_(){
 $curl $RTX3060 $RTX3070 $RTX3080 $RTX3090 $RX6700 > sales.txt
}
output_

and my cron job that should run every minute from november to december

#!/bin/bash
*/1 * * nov-dec *  /user/bin/bash /sells_Cards/sold.sh

I can't understand why the job it's not running by itself, I have to type the ./sold.sh in order to run the script.

The idea is that I have to create a script that takes as entry an API (the sales per minute of the largest graphics card vendors) and as an output the number of grapihic cards sold on each minutes( rtx3060, rtx3070, rtx3080, rtx3090 et rx6700) the results should be stored in a sales.txt file. I have created a directory under home named sells_Cards (/home/ubuntu/sells_Cards) and under this directory the sales.txt and the script sold.sh. I used crontab -e to create the job as mentioned above.

Please help me to find the pb(by the way I dont know a lot(only few) of bash scripting)Thanks in advance

CodePudding user response:

curl accepts only 1 url in the command line

Usage: curl [options...] <url>

so you need something like this (an array would be much better though)

output_() {
 {
     $curl $RTX3060
     $curl $RTX3070
     $curl $RTX3080
     $curl $RTX3090
     $curl $RX6700
 } > sales.txt
}
  • Related