Browsing articles tagged with "crontab - Admins Goodies"
May 30, 2012
tom

Crontab and rkhunter Scheduling

I’ve got a system with Ubuntu 12.04 which has rkhunter installed. Currently the rkhunter daily scan script is located in /etc/cron.daily/rkhunter. Every day at 7pm EST the rkhunter script is executed and the following is added to the /var/log/rkhunter.log file: Info: Start date is Tue May 22 19:00:29 EDT 2012 However, here are the contents of my /etc/crontab file: SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# m h dom mon dow user command 17 * * * * root cd [...]

Continue Reading »
May 25, 2012
tom

crontab schedule for every X hour

When scheduling a job every x hours, how to tell which hours will be picked? For example, we have a cronjob set for */8 which is run at 2AM, 10AM, etc. instead of midnight, 8AM, etc. Asked by Raphink Show the cron logs that prove this. Perhaps cron or the system runs on a different timezone? Answered by adaptr Check more discussion of this question. Bookmark on Delicious Digg this post Recommend on Facebook share [...]

Continue Reading »
May 23, 2012
tom

Linux execute permissions

-rw-r–r–. 1 myusername developers 169 May 17 09:01 build.sh Why is it I can execute the build.sh script from the command line if it does not have execute permissions but when crontab tries to execute it, it fails? Asked by DD. You can’t execute that from the command line, because it doesn’t have execute permissions. What you can do, is to source it from the command line, . ./build.sh which causes the current shell to [...]

Continue Reading »
May 2, 2012
tom

Daily Cron Job Example

I want to run a command daily on an Ubuntu Linux box @ 9:15PM. Is this the correct entry for my crontab? 15 23 * * * <<command>> Asked by Trent Scott The syntax is, the hours not minute hour dayofmonth month dayofweek command Your command will run every day at 23:15 (11:15pm) 9pm is 21 (in 24h writing 12 + 9 = 21) 15 21 * * * command Answered by mulaz Check more [...]

Continue Reading »
Apr 25, 2012
tom

script to remove all files in /tmp from a certain user

One of my server daemons uses a lot of space in /tmp. Because I don’t want to reboot my machine when the server runs out of disk space, I need to run a CRON script that removes old temporary files. What would be good a way to recursively remove all files and directories under /tmp which are more than 1 hour old from user , say www-data? Of course it should not resolve symlinks and [...]

Continue Reading »
Apr 17, 2012
tom

Cron doesn’t execute command after % sign in it

I have the following command in cron: 5 6 * * * bash -c “tar -czf /backups/sites-server-files-rotate/sites_`date +%F`.tar.gz /backups/sites-server-files/” But command doesn’t get executed. And I can see the following in the cron log: Apr 17 06:05:01 backup crond[9423]: (root) CMD (bash -c “tar -czf /backups/sites-server-files-rotate/sites_`date +) It seems like % sign cuts the command in cron. Why? Do I have to escape it? And how? Asked by FractalizeR Yes you do have to escape [...]

Continue Reading »
Apr 17, 2012
tom

escaping double quotes and percent signs (%) in cron

The following command works from prompt but not from crontab. grep abc /var/log/messages | grep “`date ‘+%B %d’`” | mail -s”abc log of `hostname`” shantanu.oak+`hostname`@gmail.com I need to add it to daily cron. Asked by shantanuo You have to escape the % signs. They have a special meaning in crontabs: man (5) crontab:Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % [...]

Continue Reading »
Mar 30, 2012
tom

Crontab schedule in different timezones

I would like to schedule my tasks in EST but I want the actual task to run under the default system timezone. Whats the best way of doing this? Thxs, D Asked by DD. In CENTOS version of cron just add the line: CRON_TZ=America/New_York This will run the schedule according to New York time but the task will run in the default time zone. Answered by DD. Check more discussion of this question. Bookmark on [...]

Continue Reading »
Mar 27, 2012
tom

My CRON job won’t run, any ideas?

I’ve installed the following CRON job using ‘crontab -e’ through putty on my server, but it won’t run and I have no idea why. This is the line I’m putting in and saving using ‘crontab -e’: 00 09-18 * * 1-5 /usr/bin/php5 /home/a/v/ava/public_html/p/app_availability_updates_flush.php It’s a simple script I want to run on the hour during business hours. When I use ‘crontab -l’ it prints the following: 00 09-18 * * 1-5 /usr/bin/php5 /home/a/v/ava/public_html/p/app_availability_updates_flush.phproot@ds6639:~# Does that [...]

Continue Reading »
Mar 14, 2012
tom

cron job timing

I would like to start cron job at 9:30 and then work every 5 minutes and then stop at 16:30 everday. Is this kind of scheduling possible in one or do I have to need two cron jobs? Asked by mustafa I think something along the lines of: 30/5 9-16 * * * /usr/bin/script_to_run.sh See the wiki page for details of timing syntax. I suggest testing this with a script that logs the time it [...]

Continue Reading »
Pages:1234567...17»