简体   繁体   中英

Run a cron job now

I have a shell script called import.sh . This script will be used only once and will run for atleast 2 days.

I am able to schedule a cronjob like below.

02 10 25 7 * while IFS=',' read a;do /home/$USER/import.sh $a;done < /home/$USER/input/xaa

input.sh is the shell script

xaa is the file that contains arguments.

Now I want to run this script now.

I have tried ./import.sh xaa and sh -x import.sh xaa but If I run them in a terminal then I have to leave the terminal open for the time the script runs which might take more than 2 days.

How can I schedule the job to run now and terminate as soon as it finishes.

When using the command line interface for Linux , prefixing any command with nohup prevents the command from being aborted if you log out or exit the command line interface.

So you can do something like below.

nohup ./import.sh xaa

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM