How to make cronjobbable script to load hours?

I asked a similar question :( Download the synchronization script ), but then changed it and realized that now another question.

I want to make a script called uploadtimer.sh that uploads files to different hosts and then marks the upload time to the log file. Thanks to those who helped me, I have a partial solution, but I'm stuck:

I used this as crontab (testing it for the first ten minutes after 11 a.m.)

1,2,3,4,5,6,7,8,9,10     11     *     *     *          /usr/bin/time -a /usr/local/apache/sites/$MYEMPLOYER/upload_test/output.log  /usr/local/apache/sites/$MYEMPLOYER/upload_test/uploadtimer.sh

upload_test / contains the following files:

upload_test / output.log upload_test / uploadtest.gif upload_test / uploadtimer.sh

output.log is a text file that I renamed to a .log file. This is empty. Before I posted it there, I received messages saying that "this file does not exist." I thought this would create for me, but I think not. After I created it, he continued to speak in crontab letters, which I could not write until I changed my permissions, so I did it.

uploadtest.gif is a gif

uploadtimer.sh:

#!/bin/sh

HOST='--myhost--'
USER='--login--'
PASSWD='--password--'
FILE='uploadtest.gif'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE

quit
END_SCRIPT
exit 0

The message cron sends me is:

0.00user 0.00system 0:00.02elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+253minor)pagefaults 0swaps

But there was no ftp and nothing was written to output.log.

+3
source share
3 answers

Create another script that runs the second command. Call the second script from cron.

, everthing, cron , script.

0

:

  • , ?

    crontab, cron. cron , . , cron, :

    0 2 * * * /usr/bin/time -a ~/output.log ~/uploadtimer.sh

    , 2 ( 0, 2, , , ). crontab http://www.adminschoice.com/docs/crontab.htm.

    cron, crontab -e, vi. , . cron. vi, :

    • , crontab -e,
    • i,
    • ,
    • ESC,
    • :, - .
    • wq Enter - W Q . crontab: installing new crontab.

    vi, ESC , :, , q!, (.. ), .

  • script, script?

    .

0

You might want to check out "ncftp". This will compress your boot command into "ncftpput -u $ USER -p $ PASSWD $ HOST / $ FILE" and then you won’t need a script at all, just put the whole command in your crontab:

0 2 * * * /usr/bin/time -a ~/output.log ncftpput -u $USER -p $PASSWD $HOST / $FILE
0
source

Source: https://habr.com/ru/post/1718954/


All Articles