我执行一个复杂的sh脚本,是别人给的. 就定位fuza.sh
我用ssh连接进入linux的时候,执行这个脚本没有任何问题,可以正常执行.但是我把fuza.sh放到rc.local中 或者是做成 service来执行.都不能成功.
2016-04-14 18:11:12 INFO - terminate called after throwing an instance of 'std::logic_error'
2016-04-14 18:11:12 INFO - what(): basic_string::_S_construct NULL not valid
2016-04-14 18:11:12 INFO - Stack trace:
2016-04-14 18:11:12 INFO - /lib64/libc.so.6(+0x326a0) [0x7f3871f126a0]
2016-04-14 18:11:12 INFO - gsignal
2016-04-14 18:11:12 INFO - abort
2016-04-14 18:11:12 INFO - __gnu_cxx::__verbose_terminate_handler()
2016-04-14 18:11:12 INFO - /usr/lib64/libstdc++.so.6(+0xbcbd6) [0x7f38729bebd6]
2016-04-14 18:11:12 INFO - /usr/lib64/libstdc++.so.6(+0xbcc03) [0x7f38729bec03]
2016-04-14 18:11:12 INFO - /usr/lib64/libstdc++.so.6(+0xbcd22) [0x7f38729bed22]
2016-04-14 18:11:12 INFO - std::__throw_logic_error(char const*)
2016-04-14 18:11:12 INFO - /usr/lib64/libstdc++.so.6(+0x9ce59) [0x7f387299ee59]
2016-04-14 18:11:12 INFO - std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
2016-04-14 18:11:12 INFO - /usr/autodesk/maya2016/lib/libMC3.so.8(+0xb7330) [0x7f3870d7a330]
2016-04-14 18:11:12 INFO - /usr/autodesk/maya2016/lib/libMC3.so.8(+0x139c7f) [0x7f3870dfcc7f]
2016-04-14 18:11:12 INFO - /usr/autodesk/maya2016/lib/libMC3.so.8(+0xb7f69) [0x7f3870d7af69]
2016-04-14 18:11:12 INFO - CMLFacade::Initialize(CMLWaypoint*, wchar_t const*, wchar_t const*, wchar_t const*, int, unsigned int, long long, long long, MC3_MODE, wchar_t const*)
2016-04-14 18:11:12 INFO - TCIPClient::initialize()
2016-04-14 18:11:12 INFO - TCIPClient::TCIPClient()
2016-04-14 18:11:12 INFO - TCIPClient::theOne()
2016-04-14 18:11:12 INFO - TbaseApp::cipReportStartup()
2016-04-14 18:11:12 INFO - TbaseApp::initGeneral()
2016-04-14 18:11:12 INFO - /usr/autodesk/maya2016/bin/maya.bin() [0x415d82]
2016-04-14 18:11:12 INFO - Tapplication::start()
2016-04-14 18:11:12 INFO - /usr/autodesk/maya2016/bin/maya.bin() [0x40e8af]
2016-04-14 18:11:12 INFO - main
2016-04-14 18:11:12 INFO - __libc_start_main
2016-04-14 18:11:12 INFO - /usr/autodesk/maya2016/bin/maya.bin() [0x40e06d]
2016-04-14 18:11:12 INFO - Segmentation fault
2016-04-14 18:11:12 INFO - // Maya exited with status 139
2016-04-14 18:11:12 INFO - exit return code is: 139
所有环境变量都按照ssh连接进去的环境变量设置仍然不能够成功执行,不被逼无奈只好进行模拟ssh登录来执行.还真有办法可以模拟ssh登录后执行.最后在/etc/rc.local中模拟ssh远程执行.而且记得cmd要用nohup保证后台正常执行.
ssh localhost "cmd
”
不过做这个事情首先要做ssh无密码登录.
ssh-keygen -t rsa -P ""
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys