I have two python scripts:
#1. getUrl.py # used to collect target urls which takes about 10 mins and used as the input for the next script #2. monitoring.py # used to monitoring the website. 00 01 * * * /usr/bin/python /ephemeral/monitoring/getUrl.py > /ephemeral/monitoring/input && /usr/bin/python /ephemeral/monitoring/monitoring.py >> /ephemeral/monitoring/output
I put the this command in crontab and wondering how could I write that long command into two or three lines. Something like the python line separator example below but for Crontab command, so it is more readable:
>>> print \ ... 'hel\ ... llo' helllo
You should not assume that the crontab has the same syntax as the shell script. The command field (the rest of the line) is the command to be run. The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the crontab.
There is no way to split a single command line onto multiple lines, like the shell's trailing "\". You can put the commands in a script and run it.
Understand your cron jobsCron requires that each entry in a crontab end in a newline character. If the last entry in a crontab is missing the newline, cron will consider the crontab (at least partially) broken and refuse to install it.
What does * mean in Cron? The asterisk * is used as a wildcard in Cron. * sets the execution of a task to any minute, hour, day, weekday, or month.
No, you can't do that. From the man page:
There is no way to split a single command line onto multiple lines, like the shell's trailing "\".
You can put the commands in a script and run it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With