It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .
Scheduling a Job For a Specific Time The basic usage of cron is to execute a job in a specific time as shown below. This will execute the Full backup shell script (full-backup) on 10th June 08:30 AM. The time field uses 24 hours format.
Show activity on this post. ->cron('0 */12 * * *'); This cron will run the scheduler at every 12 hours.
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
*
in the value field above means all legal values as in braces for that column.
You could use 0 1,13 * * *
which means for every 1AM and 1PM.
0 1,13 * * * rm /var/www/*/somedir/index.php > /home/someuser/cronlogs/some.log 2>&1
where *
can be replaced by different domain names.
I think the right way is -> 1 */12 * * *
(actually, any number in the minute position will do the trick.)
If you set -> * */12 * * *
it will be executed every minute at 12h and again at 24h.
Assuming your sites live in /var/www/sitename and you have the php shell installed in /usr/bin/php you can easily create a cron job that runs all those files.
run
crontab -e
and add this line
42 */12 * * * /usr/bin/php /var/www/*/somedir/index.php >> ~/cronjob.log 2>&1
The * here in /var/www/*/somedir is just a wildcart. This means it will catch every directory in your /var/ww folder.
f.ex:
[jens@localhost ~]$ ls -l temp
total 28
-rw-rw-r--. 1 jens jens 1641 Feb 21 16:12 somefile.py
drwxrwxr-x. 2 jens jens 4096 Feb 22 15:10 test
drwxrwxr-x. 2 jens jens 4096 Feb 22 15:10 test2
drwxrwxr-x. 2 jens jens 4096 Feb 22 15:10 test3
drwxr-xr-x. 8 jens jens 4096 Jan 27 10:21 emptydir
-rw-rw-r--. 1 jens jens 548 Jan 27 16:15 Unsaved Document 1
[jens@localhost ~]$ ls temp/*/testfile.php
temp/test2/testfile.php temp/test3/testfile.php temp/test/testfile.php
As you can see, this returns the testfile.php in each subfolder of temp, namely folder test, test2 and test3. Emptydir is also a folder, but since it has no testfile.php in it, nothing willhappen with it.
Use "*/12" to mean "every 12 hours."
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