Yes — as long as it is:
- code that resides outside of the web root, and is executed by cron, OR
- written as a WP plugin or theme function that adheres to WordPress security best practices.
If the code does not need to co-exist on the same physical box (i.e., it can talk via web service to the WordPress instance), another option would be to run it on a separate AWS instance hosted in the same datacenter. It would have a low-latency connection to the VPS in that scenario and run under its own environment. AWS has a program under which T2.Micro instances are free for the first year.
For additional information regarding this setup, please contact sales.