Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# Start the run once job.
echo "Docker container has been started"
# Setup a cron schedule
echo "* * * * * /run.sh >> /var/log/cron.log 2>&1
# This extra line makes it a valid cron" > scheduler.txt
crontab scheduler.txt
cron -f
@peter279k

This comment has been minimized.

Copy link

@peter279k peter279k commented Dec 30, 2019

It looks like it misses the " on line 7. And I think the fixed snippets are as follows:

echo "* * * * * /run.sh" >> /var/log/cron.log 2>&1
@peter279k

This comment has been minimized.

Copy link

@peter279k peter279k commented Dec 30, 2019

I think the line 7 and line 8 are on the same line. And the snippet should look like:

#!/bin/bash

# Start the run once job.
echo "Docker container has been started"

# Setup a cron schedule
printf "* * * * * /run.sh >> /var/log/cron.log 2>&1\n# This extra line makes it a valid cron" > scheduler.txt

crontab scheduler.txt
cron -f
@nehabhardwaj01

This comment has been minimized.

Copy link
Owner Author

@nehabhardwaj01 nehabhardwaj01 commented Dec 30, 2019

@peter279k Yes, it can be rewritten in a single line as you suggested. The only difference is the former one serves better clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment