DirectAdmin command line tasks (dataskq).

By | December 25, 2013

DirectAdmin has quite a few tasks that can be handled using the Command Line Interface by saving an action to “/usr/local/directadmin/data/task.queue“. These tasks are then executed by dataskq, which is invoked by cron every minute. Once the task is done, the task.queue file is removed. Some useful actions can be found below, and are the actual commands you need to type on the command line. If you do not want to wait for cron to start dataskq after you “echoed” something to the task.queue file, then you can also invoke it manually by typing:

[[email protected] /]# /usr/local/directadmin/dataskq

Note that some tasks (for example a full tally) can take quite a long time on servers that hold a lot of users. You can usually see some progress by watching the “top” command, to see if the dataskq process is still running. This article will expand on only the dataskq tasks. Other command line options will be discussed in a future article.

License and DirectAdmin tasks:

Update License:
[[email protected] /]# echo "action=update&value=license" >> /usr/local/directadmin/data/task.queue
Update DirectAdmin:
[[email protected] /]# echo "action=update&value=program" >> /usr/local/directadmin/data/task.queue

In case the license is no longer working, you can obtain a new license file by going to:

[[email protected] /]# cd /usr/local/directadmin/scripts/

And typing:

[[email protected] /]# sh getLicense.sh 1234 9876543

Where the first number is your client ID, and the second number is the license ID. After that, you may need to restart DirectAdmin:

[[email protected] /]# service directadmin restart

Tally’s

The nightly tally is usually invoked by cron during the night, and updates the user/domain statistics such as how much bandwidth and diskspace is used, as well as the awstats or webalizer statistics. The tally can also be invoked manually by typing:

[[email protected] /]# echo "action=tally&value=all" >> /usr/local/directadmin/data/task.queue

If you have a lot of users on your DirectAdmin system, then the tally can also be run for just one user:

[[email protected] /]# echo "action=tally&value=username&type=user" >> /usr/local/directadmin/data/task.queue

Substitute “username” for the actual directadmin username that needs to be updated.

The tally can also run for a whole reseller and all users under his/her control:

[[email protected] /]# echo "action=tally&value=resellername&type=reseller" >> /usr/local/directadmin/data/task.queue

Substitute “resellername” for the actual directadmin reseller that needs to be updated.

Apache restarted by Tally:

The tally does run every night, and one of the steps included in this tally is to restart apache. This can in some cases have an adverse effect (e.g. downloads being broken off). To remedy this, you can instruct DirectAdmin to do a graceful restart. To enable this, edit the directadmin.conf file:

[[email protected] /]# nano /usr/local/directadmin/conf/directadmin.conf

And change the “graceful_restarts” option to 1 (or add it if it is not already there):

graceful_restarts=1

Save the config file, and restart DirectAdmin.

Tally frequency:

The default value is to make it run at 10 minutes after midnight. It is also possible to make the tally more run frequently than that, by editing the crontab that invokes the tally. This can be found in “/etc/cron.d/directadmin_cron”. When you edit this file (though nano can be used, it is best practise to use vi for this), it will display a few DirectAdmin tasks. Edit this one:

10 0 * * * root echo ‘action=tally&value=all’ >> /usr/local/directadmin/data/task.queue

10 0 means it runs every day at 10 past midnight. You can change it to for example 10 */12 to make it run every 12 hours:

10 */12 * * * root echo ‘action=tally&value=all’ >> /usr/local/directadmin/data/task.queue

After you are content with the changes, you can save the file and restart crond:

[[email protected] /]# service crond restart

After every 1st of the month at 4:20 am, DirectAdmin resets the monthly bandwidth totals. This can also be run manually for the whole system or a single user:

Bandwidth Resets

Monthly Reset:
[[email protected] /]# echo "action=reset&value=all" >> /usr/local/directadmin/data/task.queue
Reset one User:
[[email protected] /]# echo "action=reset&value=username&type=user" >> /usr/local/directadmin/data/task.queue

Substitute “username” for the actual directadmin username that needs to be updated.

An interesting article about what to do when the bandwidth does not reset: http://help.directadmin.com/item.php?id=255

Httpd config files rewriting

Sometimes it is useful to rewrite the httpd config files for all users. For example if you made a mistake somewhere, or made changes to the httpd templates. This can be done with:

[[email protected] /]# echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue

 

Show all Users cache

Sometimes (rare cases) the values on the Show all Users page are not correct (or not populated). To save server resources, the data on the Show all Users page is cached data. That is stored in the following file:

/usr/local/directadmin/data/admin/show_all_users.cache

This file can also be safely removed, which will cause DirectAdmin to display the Show all Users content manually until it is either automatically recached or you recache it manually.

To recache the ‘Show all Users’ page:

[[email protected] /]# echo "action=cache&value=showallusers" >> /usr/local/directadmin/data/task.queue

To recache a user in the ‘Show all Users’ page:

[[email protected] /]# echo "action=cache&value=showallusers&user=username" >> /usr/local/directadmin/data/task.queue

Substitute “username” for the actual DirectAdmin username that needs to be updated.

Making Backups

Even backups can be run using the command line. It is usually easier to do using the “Admin Backup/Transfer” option in DirectAdmin’s Graphical User Interface (GUI), but there are instances where this interface is not or no longer available. Such as when your license is invalidated, or somehow the server has become so corrupted that the GUI is no longer available. The commands below assume you have enough space on the server’s hard drive to store the backups.

To make a backup of ALL users:

[[email protected] /]# echo "action=backup&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&type=admin&value=multiple&when=now&where=local&who=all" >> /usr/local/directadmin/data/task.queue

This can be hard to read due to the hex encoded slashes (%2F) and underscore (%5F), which are needed. The backup location in this example is filled in after the “path=”, and is /home/admin/admin_backups (%2Fhome%2Fadmin%2Fadmin%5Fbackups). No other values need to be changed.

Similar to the above example for all users, a backup can also be made for just one user:

[[email protected] /]## echo "action=backup&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&select%30=username&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue

Again, the path after “path=%2F” is the location for the backup file, and the value after “select%30=” is the username to be backupped.

If cron is no longer working, then the dataskq process to run the backup can be run manually by:

[[email protected] /]# /usr/local/directadmin/dataskq d200

Where d200 is Debug Level 200, which gives you some visible information on your console.

Conclusion

There are more tasks that can be fed to the task.queue file, and I may expand on this article at a later date. There are also many more tasks, not related to dataskq, that can be done using the command line. I will create a separate article for that.

2 thoughts on “DirectAdmin command line tasks (dataskq).

  1. Harry Betlem

    Nice to read all these options, but I am a ‘regular’ user, i.e. my website is hosted at a host where DirectAdmin is installed. I do not have the admission to get to that level.
    Or are there ways to do this, just to stop spam being sent in name of [root]@temp.[hostname].net ?
    We, the hoster and I have been resetting the main password several times. It is NOT saved in a browser, not in my ftp.
    Or is there a way to search for the malicious files using php?

    Any solution would be welcome

    Reply
  2. Jeroen Wierda Post author

    I do not know of a way to scan for malicious file susing PHP, but there is scanning software available called “maldetect”: https://www.rfxn.com/projects/linux-malware-detect/

    You could also (from the commandline) do:

    Scan the whole hosting environment for all files containing eval(base64_decode(
    grep -r “eval(base64_decode(” /home/*/domains/*/public_html

    This will not find all files, but does look for that code string that is most often injected.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *