Page 1 of 1

How to suspend user account autonatically with cron job?

Posted: Fri Aug 24, 2018 5:34 am
by emammadov
Could you please help me to solve this with cron job? Suspend user command is: v-suspend-user

How can I suspend a user for example called loqopedplus with command?

I added cron with this command "sudo /usr/local/vesta/bin/v-suspend-user loqopedplus" but it didn't work. But when I enter this command in putty it works. I add print screen here.

https://drive.google.com/open?id=1UTemI ... 0HpNHJWPcn

I get email notification for this.

/usr/local/vesta/bin/v-suspend-user: line 17: /func/main.sh: No such file or directory
/usr/local/vesta/bin/v-suspend-user: line 18: /conf/vesta.conf: No such file or directory
/usr/local/vesta/bin/v-suspend-user: line 25: check_args: command not found
/usr/local/vesta/bin/v-suspend-user: line 26: is_format_valid: command not found
/usr/local/vesta/bin/v-suspend-user: line 27: is_object_valid: command not found
/usr/local/vesta/bin/v-suspend-user: line 28: is_object_unsuspended: command not found
/usr/local/vesta/bin/v-suspend-user: line 77: /v-restart-web: No such file or directory
/usr/local/vesta/bin/v-suspend-user: line 78: check_result: command not found
/usr/local/vesta/bin/v-suspend-user: line 80: /v-restart-dns: No such file or directory
/usr/local/vesta/bin/v-suspend-user: line 81: check_result: command not found
/usr/local/vesta/bin/v-suspend-user: line 83: /v-restart-cron: No such file or directory
/usr/local/vesta/bin/v-suspend-user: line 84: check_result: command not found
/usr/local/vesta/bin/v-suspend-user: line 87: update_user_value: command not found
/usr/local/vesta/bin/v-suspend-user: line 88: increase_user_value: command not found
/usr/local/vesta/bin/v-suspend-user: line 91: log_event: command not found

Re: How to suspend user account autonatically with cron job?

Posted: Fri Aug 24, 2018 5:24 pm
by ScIT
v-suspend-user is not setup for running as cron job, i think following part is missing:

Code: Select all

# Importing system variables
source /etc/profile
But I think the best way for you is to use the api, for example using a small php script (you can run it over cron) or another way is to use a customer panel like whmcs.

Re: How to suspend user account autonatically with cron job?

Posted: Wed Aug 29, 2018 6:27 pm
by emammadov
Coudl you please write complete form of that cron job?, sudo v-suspend-user loqopedplus source /etc/profile?

Re: How to suspend user account autonatically with cron job?

Posted: Thu Aug 30, 2018 7:14 am
by ScIT
emammadov wrote:
Wed Aug 29, 2018 6:27 pm
Coudl you please write complete form of that cron job?, sudo v-suspend-user loqopedplus source /etc/profile?
No I can't, in my point of view this is a special customization and not really vesta support. Please use vesta support (https://vestacp.com/support/) or contact any sysadmin, that have at least a little bit knowledge of bash or php scripting.

Re: How to suspend user account autonatically with cron job?

Posted: Fri Aug 31, 2018 7:27 am
by xorro

Code: Select all

v-add-cron-job USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] [RESTART]
Well this is the command to add cron job via cli but the work you want to get done is bit scary and cannot be done directly via cron job. reason is you cannot define which user to suspend in 1 command. Like if a user account is expiring on today and another one is expiring on next day then how cron job will know which one to suspend.
I have 2 idea's to get this done.
1: add a specific user cron job for suspension and schedule it for that specific date when you want that user to be deleted so command will run on that date only and after that it will be expired. you can add as many suspension command for each users you want. That is the most easy way.
Second solution works almost as above write a script in shell and define a time or date to suspend that user on that date or time add as many lines of commands you want in that script and then add that shell script to cron job.

i know i did not explained much but if you are a bit of genius you will get to the point and will get this done.