List all accounts php version
Forum
  1. Forums
  2. General
  3. General Discussion
  1. Nuno Leite
  2. 06.02.2019
  3.  Subscribe via email
Hi!

I would like to know if there is a way to list all accounts php version.
I have this command line:

ls -1 /var/cpanel/users | grep -v "\." | awk '{ print "selectorctl --interpreter=php --user-summary --user="$1 }' | sh

But this returns something like this:

5.3 e - -
5.4 - - -
5.5 - - -
5.6 e - s
7.0 e - -
7.1 e d -
7.2 e - -
7.3 e - -
native e - -
5.3 e - -
5.4 - - -
5.5 - - -
5.6 e - s
7.0 e - -
7.1 e d -
7.2 e - -
7.3 e - -
native e - -
5.3 e - -
5.4 - - -
5.5 - - -
5.6 e - s
7.0 e - -
7.1 e d -
7.2 e - -
7.3 e - -
native e - -

Then i have to run this:

ls -1 /var/cpanel/users | grep -v "\."

To have the accounts list.

After this i have to go account by account by the same exact order to see what is the selected php version of every account.
I have more than 100 on a server.

So, is there a command to list the accounts php selected? For example like this:

account1 5.5
account2 7.0
account3 7.0
account4 5.6
account5 7.1
etc...


A better way would be to have some panel to see a list of all accounts and manage the php version from the CloudLinux LVE Manager.

Thanks
Nuno Leite
Rate this post:
  1. 06.02.2019 13:02:30
  2. # 1
Vladimir Accepted Answer
Posts: 101
Joined: 04.07.2017
0
Votes
Undo
Hello,

Since PHP Selector based on CageFS, you can get the list of users with PHP Selector enabled with the following command:
# cagefsctl --list-enabled

In order to check the current PHP version per user, you should use the following command:
# selectorctl -c -u $username

By combining these two commands you can achieve your goal and get the list of PHP versions per account.
  1. 06.02.2019 17:02:37
  2. # 2
Nuno Leite Accepted Answer
Posts: 10
Joined: 30.08.2018
0
Votes
Undo
Hi!

Thanks i didn't know that second command.
So i tried to combine some options and found these 2 options:
# cagefsctl --list-enabled | xargs -t -n1 selectorctl -c -u
# ls -1 /var/cpanel/users | grep -v "\." | xargs -t -n1 selectorctl -c -u

Both work, but i think the second command is better has i can even get the users that fail so i know what users are out of CageFS.

These commands return something like this:
selectorctl -c -u account1
7.1 7.1.26 /opt/alt/php71/usr/bin/php-cgi
selectorctl -c -u account2
7.0 7.0.33 /opt/alt/php70/usr/bin/php-cgi
selectorctl -c -u account3
5.6 5.6.40 /opt/alt/php56/usr/bin/php-cgi

For what i need i think this is enough, because i can have a small list with the accountname and the php version combined.

Thanks
Nuno Leite
  1. 22.06.2019 20:06:51
  2. # 3
Posts: 0
Joined: 21.10.2020
0
Votes
Undo
\

for user in $(ls -1 /var/cpanel/users) ; do version=$(selectorctl -c -u $i | awk '{print $1}' ) ; echo $user $version ; done


user1 5.6
user2 5.6
user3 5.6
  1. 23.06.2019 14:06:22
  2. # 4
Sergey Khristich Accepted Answer
Posts: 464
Joined: 20.05.2019
0
Votes
Undo
Hello Justin, Thank you.
Please let us know if you have any questions.
Thanks in advance!
Marketing Manager
  1. 24.06.2019 09:06:45
  2. # 5
Nuno Leite Accepted Answer
Posts: 10
Joined: 30.08.2018
0
Votes
Undo
Hi Justin,

Thanks, this works great.

I just had to change the "$i" to "$user"

for user in $(ls -1 /var/cpanel/users) ; do version=$(selectorctl -c -u $user | awk '{print $1}') ; echo $user $version ; done


Thanks.
Nuno Leite
  1. 24.06.2019 09:06:51
  2. # 6
Sergey Khristich Accepted Answer
Posts: 464
Joined: 20.05.2019
0
Votes
Undo
Hello Nuno,
Happy to hear it and thanks for following up!
Marketing Manager
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!
Justin C. - BigScoots.com
Submit Your Response
Upload files or images for this discussion by clicking on the upload button below. Supports gif,jpg,png,zip,rar,pdf
• Insert • Remove Upload Files (Maximum File Size: 2 MB)
Captcha
To protect the site from bots and unauthorized scripts, we require that you enter the captcha codes below before posting your question.