Current time: 11-24-2024, 05:06 AM Hello There, Guest! (LoginRegister)


Post Reply 
[HowTo] Cron for customers
Author Message
Blondak Offline
Junior Member
*****
Dev Team

Posts: 84
Joined: May 2008
Reputation: 5
Post: #1
[HowTo] Cron for customers
Hi,
i have small script for support cron on virtual accounts just create file and add to cron

Code:
#!/bin/bash

CRON_BASE_DIR=/var/www/virtual/
CRON_BASE_PERM=/var/www/virtual/
MODE=daily

if [ "$1" ==  "exec" ]; then
    if [ ! -f "$2" ]; then
    exit 1
    fi
    
    owner="$( echo $2 | sed "s^\($CRON_BASE_PERM[^/]\+\).*^\1^g" )"
    owner="$( stat -c %U "$owner" )"
    base="$( dirname $2 )"
    cwd="$( pwd )"
    cd "$base"
    sudo -u $owner "$2"
    cd "$cwd"
    exit 0
fi

find "$CRON_BASE_DIR" -regex ".*\/\(cron/$MODE\)\/.*" -type f -perm /0111 -exec $0 exec '{}' \;

this script looks in domain folder for folder cron/daily and if found some executable exec as user who owns /var/www/virtual/domain.tld
(This post was last modified: 11-25-2008 03:05 AM by BeNe.)
10-08-2008 02:10 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
[HowTo] Cron for customers - Blondak - 10-08-2008 02:10 AM
RE: Cron for customers - BeNe - 10-08-2008, 03:20 AM
RE: Cron for customers - FeG - 10-11-2008, 06:24 AM
RE: [HowTo] Cron for customers - mishas - 07-07-2009, 10:08 PM
RE: [HowTo] Cron for customers - BeNe - 07-08-2009, 02:34 AM
RE: [HowTo] Cron for customers - aseques - 07-09-2009, 09:05 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)