January 2, 201412 yr Hi, I want to add a script that checks/repairs the permissions of a specific folder... I can easily change via "crontab -e" to add my custom script... but these changes do not survive a server reboot. How can I make this change permanent. Any help is greatly appreciated. Thanks, Hernando
January 2, 201412 yr You could add it to your go script crontab -l > /tmp/file echo '#' >> /tmp/file echo '# Start of Custom crontab entries' >> /tmp/file echo '10 05 * * * /boot/scripts/yourscript 1>/dev/null 2>&1' >> /tmp/file echo '# End of Custom crontab entries' >> /tmp/file crontab /tmp/file rm -f /tmp/file
January 2, 201412 yr Author Thank you Graywolf.... When it starts up, there is already content when I type "crontab -e". In reading your script, I see that you are using the line below to load the values from a script built file: crontab /tmp/file Will this overwrite the default cron content? I really don't know much about cron. Also, for simplification, can I put a text file in /boot/ with the crontab lines...? Then in my go script? crontab /boot/mycrontab.txt Again, many thanks for your help. H.
January 2, 201412 yr Thank you Graywolf.... When it starts up, there is already content when I type "crontab -e". In reading your script, I see that you are using the line below to load the values from a script built file: crontab /tmp/file Will this overwrite the default cron content? I really don't know much about cron. No, it does not. The first line saves the existing content. Also, for simplification, can I put a text file in /boot/ with the crontab lines...? Then in my go script? crontab /boot/mycrontab.txt The go file code will thus be as follows: crontab -l > /tmp/file echo '#' >> /tmp/file echo '# Start of Custom crontab entries' >> /tmp/file cat /boot/mycrontab.txt >> /tmp/file echo '# End of Custom crontab entries' >> /tmp/file crontab /tmp/file rm -f /tmp/file Or you can out all of this is a file and execute that file from the go script.
January 2, 201412 yr Author Thank you both!! I will follow your guide. I really appreciate your help. :)
January 5, 201412 yr I followed this post and set up a file for myself. Unfortunately I get this errorlog. [pre][/pre] failed parsing crontab for user root: /boot/auto_s3_sleep.sh 1> /dev/null 2>$stuff$1 (Minor Issues) [pre][/pre] My crontab -l looks like this: # If you don't want the output of a cron job mailed to you, you have to direct # any output to /dev/null. We'll do this here since these jobs should run # properly on a newly installed system, but if they don't the average newbie # might get quite perplexed about getting strange mail every 5 minutes. :^) # # Run the hourly, daily, weekly, and monthly cron jobs. # Jobs that need different timing may be entered into the crontab as before, # but most really don't need greater granularity than this. If the exact # times of the hourly, daily, weekly, and monthly cron jobs do not suit your # needs, feel free to adjust them. # # Run hourly cron jobs at 47 minutes after the hour: 47 * * * * /usr/bin/run-parts /etc/cron.hourly 1> /dev/null # # Run daily cron jobs at 4:40 every day: 40 4 * * * /usr/bin/run-parts /etc/cron.daily 1> /dev/null # # Run weekly cron jobs at 4:30 on the first day of the week: 30 4 * * 0 /usr/bin/run-parts /etc/cron.weekly 1> /dev/null # # Run monthly cron jobs at 4:20 on the first day of the month: 20 4 1 * * /usr/bin/run-parts /etc/cron.monthly 1> /dev/null # # Import crontab entries from file # Start of custom crontab entries 00 1 * * /boot/auto_s3_sleep.sh 1> /dev/null 2>&1 # End of custom crontab entries# Import finished root@Tuerke:~# Appreciate your help!
January 6, 201412 yr There are 5 parameters expected prior to a command in a crontab entry..You only have 4.
January 29, 201412 yr I have another issue. In the manpage of crontab there is this: Instead of the first five fields, one of eight special strings may appear: string meaning ------ ------- @reboot Run once, at startup. @yearly Run once a year, "0 0 1 1 *". @annually (same as @yearly) @monthly Run once a month, "0 0 1 * *". @weekly Run once a week, "0 0 * * 0". @daily Run once a day, "0 0 * * *". @midnight (same as @daily) @hourly Run once an hour, "0 * * * *". When I use @reboot /boot/auto_s3_sleep.sh 1> /dev/null 2>&1 in the above script, nothing happens. I assume cron does not know about the "reboot" because when the script is executed the reboot already passed? I know, I can put the call into the go file when it's supposed to start at reboot. Just curious why it doesn't work with the crontab and it's more comfortable to edit the mycrontab.txt
Archived
This topic is now archived and is closed to further replies.