Support Center > Knowledgebase > DirectAdmin > DirectAdmin > How to reset a user on the same day of the month his account was created
How to reset a user on the same day of the month his account was created
To accomplish this, you'll need to
remove the following line from the /etc/cron.d/directadmin_cron:
40 1 1 * * root echo "action=reset&value=all" >> /usr/local/directadmin/data/task.queue
Now to get a user to be reset, you'll have to tell the system to do it via a cron job which has to be created. To do this, we'll use the custom creation scripts to do the work.
contents of /usr/local/directadmin/scripts/custom/user_create_post.sh:
#!/bin/sh
day=`date +"%d"`
if [ "$day" -gt 28 ]; then day=28; fi
echo "0 0 $day * * root echo 'action=reset&value=${username}&type=user' >> /usr/local/directadmin/data/task.queue" > /etc/cron.d/${username};
chmod 644 /etc/cron.d/${username}
killall -HUP crond
exit 0;
contents of /usr/local/directadmin/scripts/custom/user_destroy_post.sh:
#!/bin/sh
rm -f /etc/cron.d/${username}
exit 0;
Then chmod both files to 755:
chmod 755 /usr/local/directadmin/scripts/custom/user_create_post.sh
chmod 755 /usr/local/directadmin/scripts/custom/user_destroy_post.sh
If you have any existing users on your system, you'll have to manually create the files for them in /etc/cron.d/
username.
That's it :)
Note: this can be a security hole if you have other files in /etc/cron.d. For example, if someone created a user called "systat", if that script exists, it would be overwritten and it's contents would not be run.
Also Read